This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Mailer | |
{ | |
private $fromEmail; | |
private $fromName; | |
private $header; | |
public function __construct($fromEmail, $fromName, $header) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class data | |
{ | |
private $data; | |
public function __construct($data) | |
{ | |
$this->data = $data; | |
} | |
public function get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductList | |
{ | |
private $products = []; | |
public function __construct(array $productList) | |
{ | |
foreach ($productList as $product) { | |
$this->addProduct($product); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ProductListTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testProductList() | |
{ | |
$listedProduct = $this->prophesize(ProductListInterface::class); | |
$listedProduct->isListed()->willReturn(true); | |
$notListedProduct = $this->prophesize(ProductListInterface::class); | |
$notListedProduct->isListed()->willReturn(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Demo; | |
interface ProductListInterface | |
{ | |
/** | |
* Checks if the product is listed. | |
* | |
* @return bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Demo; | |
class ProductList | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests\Demo; | |
use Demo\ProductList; | |
class ProductListTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testProductList() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class data | |
{ | |
private $data; | |
public function __construct($data) | |
{ | |
$this->data = $data; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener("fetch", (event) => { | |
event.respondWith( | |
caches.match(event.request) | |
.then(response => { | |
if (response) { | |
return response; | |
} | |
// Version #1: Cache all (!) responses and return error page | |
// Clone the request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cleanup old cache storages | |
self.addEventListener("activate", event => { | |
event.waitUntil( | |
caches.keys() | |
.then(cacheNames => { | |
return Promise.all( | |
cacheNames.map(cacheName => { | |
if (CACHE_VERSION !== cacheName) { | |
return caches.delete(cacheName); | |
} |