Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Potthast danielpotthast

View GitHub Profile
View sblum-symfony--mailer-class.php
<?php
class Mailer
{
private $fromEmail;
private $fromName;
private $header;
public function __construct($fromEmail, $fromName, $header)
{
View sblum-symfony--data-class-green.php
class data
{
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function get()
View sblum-symfony--productlist-class-green.php
class ProductList
{
private $products = [];
public function __construct(array $productList)
{
foreach ($productList as $product) {
$this->addProduct($product);
}
}
View sblum-symfony--testproductlist.php
<?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);
View sblum-symfony--productlist-interface.php
<?php
namespace Demo;
interface ProductListInterface
{
/**
* Checks if the product is listed.
*
* @return bool
View sblum-symfony--productlist-test.php
<?php
namespace Tests\Demo;
use Demo\ProductList;
class ProductListTest extends \PHPUnit_Framework_TestCase
{
public function testProductList()
{
View sblum-symfony--data-class.php
<?php
class data
{
private $data;
public function __construct($data)
{
$this->data = $data;
}
View sblum-pwa--service-worker-code3.js
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
View sblum-pwa--service-worker-code2.js
// 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);
}