Skip to content

Instantly share code, notes, and snippets.

View danielpotthast's full-sized avatar

Daniel Potthast danielpotthast

View GitHub Profile
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
<?php
class data
{
private $data;
public function __construct($data)
{
$this->data = $data;
}
<?php
namespace Tests\Demo;
use Demo\ProductList;
class ProductListTest extends \PHPUnit_Framework_TestCase
{
public function testProductList()
{
<?php
namespace Demo;
class ProductList
{
}
<?php
namespace Demo;
interface ProductListInterface
{
/**
* Checks if the product is listed.
*
* @return bool
<?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);
class ProductList
{
private $products = [];
public function __construct(array $productList)
{
foreach ($productList as $product) {
$this->addProduct($product);
}
}
class data
{
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function get()
<?php
class Mailer
{
private $fromEmail;
private $fromName;
private $header;
public function __construct($fromEmail, $fromName, $header)
{
<?php
class Newsletter
{
private $mailer;
public function __construct()
{
$this->mailer = new Mailer('news@demo.de','Demo News','Reply-To: reply@demo.de');
}