Skip to content

Instantly share code, notes, and snippets.

<?php
interface Sign
{
/**
* @param string $string
* @return string
*/
public function __invoke(string $string) : string;
}
@vasildakov-zz
vasildakov-zz / AndX.php
Last active March 15, 2018 15:50
Specification Design Pattern
<?php
/**
* class AndX
* @author Vasil Dakov <vasildakov@gmail.com>
*/
class AndX extends CompositeSpecification
{
/**
* @var SpecificationInterface $left
<?php
class CachedSkuRepository implements SkuRepositoryInterface
{
private $repository;
private $cache;
public function __construct(
SkuRepositoryInterface $repository,
class Film implements FilmInterface {
public String getTitle() {}
public Float getRating() {}
public int addRating(int rating) {}
}
@vasildakov-zz
vasildakov-zz / CustomStreamHandlerFactory.php
Last active February 23, 2017 14:38
Monolog and Handlers
<?php
# generic stream handler
use Monolog\Handler\StreamHandler;
class CustomStreamHandlerFactory
{
public function __invoke(ContainerInterface $container) : StreamHandler
{
$options = $container->get(CustomStreamHandlerOptions::class);
@vasildakov-zz
vasildakov-zz / index.php
Created February 5, 2017 18:54 — forked from tuupola/index.php
Use JWT Authentication middleware with ZF Expressive
<?php
use Zend\Expressive\AppFactory;
use Firebase\JWT\JWT;
use Slim\Middleware\JwtAuthentication;
chdir(dirname(__DIR__));
require "vendor/autoload.php";
$app = AppFactory::create();
<?php
/*
Original version:
written by Jarrod Oberto
taken from http://net.tutsplus.com/tutorials/php/image-resizing-made-easy-with-php/
Example usage:
include("classes/Resize.php");
@vasildakov-zz
vasildakov-zz / cli-config.php
Created May 7, 2016 20:28 — forked from geerteltink/cli-config.php
Zend Expressive Doctrine Factory and Redis Cache
<?php
/**
* Configuration for doctrine cli.
*
* This file is auto detected and used by doctrine cli.
*/
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\EntityManager;
@vasildakov-zz
vasildakov-zz / DepotControllerTest.php
Created December 21, 2015 10:00
DepotControllerTest
<?php
// Ws\Fleet\UiBundle\Tests\Controller\DepotControllerTest.php
namespace Ws\Fleet\UiBundle\Tests\Controller;
use Ws\Fleet\UiBundle\Controller\DepotController;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
@vasildakov-zz
vasildakov-zz / doctrine.local.php
Created October 20, 2015 13:19
doctrine.local.php
<?php
// Production Config
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',