repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/SyslogUdpHandlerTest.php
tests/Monolog/Handler/SyslogUdpHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; /** * @req...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/RotatingFileHandlerTest.php
tests/Monolog/Handler/RotatingFileHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use InvalidArgumentException; u...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/FilterHandlerTest.php
tests/Monolog/Handler/FilterHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; class Filte...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/BrowserConsoleHandlerTest.php
tests/Monolog/Handler/BrowserConsoleHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; /** * @cov...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/ElasticsearchHandlerTest.php
tests/Monolog/Handler/ElasticsearchHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Formatter\Elasticse...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/GelfHandlerTest.php
tests/Monolog/Handler/GelfHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Gelf\Message; use Monolog\L...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/LogmaticHandlerTest.php
tests/Monolog/Handler/LogmaticHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; use PHPUnit\...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/FingersCrossedHandlerTest.php
tests/Monolog/Handler/FingersCrossedHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; use Monolog\...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/OverflowHandlerTest.php
tests/Monolog/Handler/OverflowHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; /** * @aut...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/SlackWebhookHandlerTest.php
tests/Monolog/Handler/SlackWebhookHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; use Monolog\...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/FleepHookHandlerTest.php
tests/Monolog/Handler/FleepHookHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Formatter\LineForma...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
tests/Monolog/Handler/AbstractProcessingHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; use Monolog\...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/RedisHandlerTest.php
tests/Monolog/Handler/RedisHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; use Monolog\...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/CouchDBHandlerTest.php
tests/Monolog/Handler/CouchDBHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; class Couch...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/MailHandlerTest.php
tests/Monolog/Handler/MailHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; class MailH...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/MongoDBHandlerTest.php
tests/Monolog/Handler/MongoDBHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use MongoDB\BSON\UTCDateTime; u...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/DeduplicationHandlerTest.php
tests/Monolog/Handler/DeduplicationHandlerTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use Monolog\Level; class Dedup...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Handler/Slack/SlackRecordTest.php
tests/Monolog/Handler/Slack/SlackRecordTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler\Slack; use Monolog\Level; use PH...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Attribute/WithMonologChannelTest.php
tests/Monolog/Attribute/WithMonologChannelTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Attribute; class WithMonologChannelTest ...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
Seldaek/monolog
https://github.com/Seldaek/monolog/blob/b321dd6749f0bf7189444158a3ce785cc16d69b0/tests/Monolog/Attribute/AsMonologProcessorTest.php
tests/Monolog/Attribute/AsMonologProcessorTest.php
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Attribute; /** * @requires PHP 8.0 */ ...
php
MIT
b321dd6749f0bf7189444158a3ce785cc16d69b0
2026-01-04T15:02:34.332473Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Builder.php
Creational/Builder/Builder.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder; use DesignPatterns\Creational\Builder\Parts\Vehicle; interface Builder { public function createVehicle(): void; public function addWheel(): void; public function addEngine(): void; public function addDoors(): void; p...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/TruckBuilder.php
Creational/Builder/TruckBuilder.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder; use DesignPatterns\Creational\Builder\Parts\Door; use DesignPatterns\Creational\Builder\Parts\Engine; use DesignPatterns\Creational\Builder\Parts\Wheel; use DesignPatterns\Creational\Builder\Parts\Truck; use DesignPatterns\Creational\Builder...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Director.php
Creational/Builder/Director.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder; use DesignPatterns\Creational\Builder\Parts\Vehicle; /** * Director is part of the builder pattern. It knows the interface of the builder * and builds a complex object with the help of the builder * * You can also inject many builders i...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/CarBuilder.php
Creational/Builder/CarBuilder.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder; use DesignPatterns\Creational\Builder\Parts\Door; use DesignPatterns\Creational\Builder\Parts\Engine; use DesignPatterns\Creational\Builder\Parts\Wheel; use DesignPatterns\Creational\Builder\Parts\Car; use DesignPatterns\Creational\Builder\P...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Parts/Door.php
Creational/Builder/Parts/Door.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder\Parts; class Door { }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Parts/Engine.php
Creational/Builder/Parts/Engine.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder\Parts; class Engine { }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Parts/Truck.php
Creational/Builder/Parts/Truck.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder\Parts; class Truck extends Vehicle { }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Parts/Car.php
Creational/Builder/Parts/Car.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder\Parts; class Car extends Vehicle { }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Parts/Vehicle.php
Creational/Builder/Parts/Vehicle.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder\Parts; abstract class Vehicle { final public function setPart(string $key, object $value) { } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Parts/Wheel.php
Creational/Builder/Parts/Wheel.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder\Parts; class Wheel { }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Builder/Tests/DirectorTest.php
Creational/Builder/Tests/DirectorTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Builder\Tests; use DesignPatterns\Creational\Builder\Parts\Car; use DesignPatterns\Creational\Builder\Parts\Truck; use DesignPatterns\Creational\Builder\TruckBuilder; use DesignPatterns\Creational\Builder\CarBuilder; use DesignPatterns\Creational\Bui...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Pool/WorkerPool.php
Creational/Pool/WorkerPool.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Pool; use Countable; class WorkerPool implements Countable { /** * @var StringReverseWorker[] */ private array $occupiedWorkers = []; /** * @var StringReverseWorker[] */ private array $freeWorkers = []; publ...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Pool/StringReverseWorker.php
Creational/Pool/StringReverseWorker.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Pool; class StringReverseWorker { public function run(string $text): string { return strrev($text); } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Pool/Tests/PoolTest.php
Creational/Pool/Tests/PoolTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Pool\Tests; use DesignPatterns\Creational\Pool\WorkerPool; use PHPUnit\Framework\TestCase; class PoolTest extends TestCase { public function testCanGetNewInstancesWithGet() { $pool = new WorkerPool(); $worker1 = $pool->get();...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/SimpleFactory/SimpleFactory.php
Creational/SimpleFactory/SimpleFactory.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\SimpleFactory; class SimpleFactory { public function createBicycle(): Bicycle { return new Bicycle(); } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/SimpleFactory/Bicycle.php
Creational/SimpleFactory/Bicycle.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\SimpleFactory; class Bicycle { public function driveTo(string $destination) { } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/SimpleFactory/Tests/SimpleFactoryTest.php
Creational/SimpleFactory/Tests/SimpleFactoryTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\SimpleFactory\Tests; use DesignPatterns\Creational\SimpleFactory\Bicycle; use DesignPatterns\Creational\SimpleFactory\SimpleFactory; use PHPUnit\Framework\TestCase; class SimpleFactoryTest extends TestCase { public function testCanCreateBicycle(...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Singleton/Singleton.php
Creational/Singleton/Singleton.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Singleton; use Exception; final class Singleton { private static ?Singleton $instance = null; /** * gets the instance via lazy initialization (created on first usage) */ public static function getInstance(): Singleton { ...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Singleton/Tests/SingletonTest.php
Creational/Singleton/Tests/SingletonTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Singleton\Tests; use DesignPatterns\Creational\Singleton\Singleton; use PHPUnit\Framework\TestCase; class SingletonTest extends TestCase { public function testUniqueness() { $firstCall = Singleton::getInstance(); $secondCall ...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/StaticFactory/FormatString.php
Creational/StaticFactory/FormatString.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\StaticFactory; class FormatString implements Formatter { public function format(string $input): string { return $input; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/StaticFactory/FormatNumber.php
Creational/StaticFactory/FormatNumber.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\StaticFactory; class FormatNumber implements Formatter { public function format(string $input): string { return number_format((int) $input); } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/StaticFactory/Formatter.php
Creational/StaticFactory/Formatter.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\StaticFactory; interface Formatter { public function format(string $input): string; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/StaticFactory/StaticFactory.php
Creational/StaticFactory/StaticFactory.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\StaticFactory; use InvalidArgumentException; /** * Note1: Remember, static means global state which is evil because it can't be mocked for tests * Note2: Cannot be subclassed or mock-upped or have multiple different instances. */ final class Stat...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/StaticFactory/Tests/StaticFactoryTest.php
Creational/StaticFactory/Tests/StaticFactoryTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\StaticFactory\Tests; use InvalidArgumentException; use DesignPatterns\Creational\StaticFactory\FormatNumber; use DesignPatterns\Creational\StaticFactory\FormatString; use DesignPatterns\Creational\StaticFactory\StaticFactory; use PHPUnit\Framework\Te...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/WinWriterFactory.php
Creational/AbstractFactory/WinWriterFactory.php
<?php namespace DesignPatterns\Creational\AbstractFactory; class WinWriterFactory implements WriterFactory { public function createCsvWriter(): CsvWriter { return new WinCsvWriter(); } public function createJsonWriter(): JsonWriter { return new WinJsonWriter(); } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/CsvWriter.php
Creational/AbstractFactory/CsvWriter.php
<?php namespace DesignPatterns\Creational\AbstractFactory; interface CsvWriter { public function write(array $line): string; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/WriterFactory.php
Creational/AbstractFactory/WriterFactory.php
<?php namespace DesignPatterns\Creational\AbstractFactory; interface WriterFactory { public function createCsvWriter(): CsvWriter; public function createJsonWriter(): JsonWriter; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/UnixWriterFactory.php
Creational/AbstractFactory/UnixWriterFactory.php
<?php namespace DesignPatterns\Creational\AbstractFactory; class UnixWriterFactory implements WriterFactory { public function createCsvWriter(): CsvWriter { return new UnixCsvWriter(); } public function createJsonWriter(): JsonWriter { return new UnixJsonWriter(); } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/JsonWriter.php
Creational/AbstractFactory/JsonWriter.php
<?php namespace DesignPatterns\Creational\AbstractFactory; interface JsonWriter { public function write(array $data, bool $formatted): string; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/UnixJsonWriter.php
Creational/AbstractFactory/UnixJsonWriter.php
<?php namespace DesignPatterns\Creational\AbstractFactory; class UnixJsonWriter implements JsonWriter { public function write(array $data, bool $formatted): string { $options = 0; if ($formatted) { $options = JSON_PRETTY_PRINT; } return json_encode($data, $options...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/UnixCsvWriter.php
Creational/AbstractFactory/UnixCsvWriter.php
<?php namespace DesignPatterns\Creational\AbstractFactory; class UnixCsvWriter implements CsvWriter { public function write(array $line): string { return join(',', $line) . "\n"; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/WinCsvWriter.php
Creational/AbstractFactory/WinCsvWriter.php
<?php namespace DesignPatterns\Creational\AbstractFactory; class WinCsvWriter implements CsvWriter { public function write(array $line): string { return join(',', $line) . "\r\n"; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/WinJsonWriter.php
Creational/AbstractFactory/WinJsonWriter.php
<?php namespace DesignPatterns\Creational\AbstractFactory; class WinJsonWriter implements JsonWriter { public function write(array $data, bool $formatted): string { $options = 0; if ($formatted) { $options = JSON_PRETTY_PRINT; } return json_encode($data, $options)...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/AbstractFactory/Tests/AbstractFactoryTest.php
Creational/AbstractFactory/Tests/AbstractFactoryTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\AbstractFactory\Tests; use DesignPatterns\Creational\AbstractFactory\CsvWriter; use DesignPatterns\Creational\AbstractFactory\JsonWriter; use DesignPatterns\Creational\AbstractFactory\UnixWriterFactory; use DesignPatterns\Creational\AbstractFactory\W...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Prototype/FooBookPrototype.php
Creational/Prototype/FooBookPrototype.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Prototype; class FooBookPrototype extends BookPrototype { protected string $category = 'Foo'; public function __clone() { } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Prototype/BarBookPrototype.php
Creational/Prototype/BarBookPrototype.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Prototype; class BarBookPrototype extends BookPrototype { protected string $category = 'Bar'; public function __clone() { } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Prototype/BookPrototype.php
Creational/Prototype/BookPrototype.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Prototype; abstract class BookPrototype { protected string $title; protected string $category; abstract public function __clone(); final public function getTitle(): string { return $this->title; } final public f...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/Prototype/Tests/PrototypeTest.php
Creational/Prototype/Tests/PrototypeTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\Prototype\Tests; use DesignPatterns\Creational\Prototype\BarBookPrototype; use DesignPatterns\Creational\Prototype\FooBookPrototype; use PHPUnit\Framework\TestCase; class PrototypeTest extends TestCase { public function testCanGetFooBook() {...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/FactoryMethod/StdoutLoggerFactory.php
Creational/FactoryMethod/StdoutLoggerFactory.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\FactoryMethod; class StdoutLoggerFactory implements LoggerFactory { public function createLogger(): Logger { return new StdoutLogger(); } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/FactoryMethod/LoggerFactory.php
Creational/FactoryMethod/LoggerFactory.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\FactoryMethod; interface LoggerFactory { public function createLogger(): Logger; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/FactoryMethod/FileLoggerFactory.php
Creational/FactoryMethod/FileLoggerFactory.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\FactoryMethod; class FileLoggerFactory implements LoggerFactory { public function __construct(private string $filePath) { } public function createLogger(): Logger { return new FileLogger($this->filePath); } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/FactoryMethod/Logger.php
Creational/FactoryMethod/Logger.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\FactoryMethod; interface Logger { public function log(string $message); }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/FactoryMethod/FileLogger.php
Creational/FactoryMethod/FileLogger.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\FactoryMethod; class FileLogger implements Logger { public function __construct(private string $filePath) { } public function log(string $message) { file_put_contents($this->filePath, $message . PHP_EOL, FILE_APPEND); ...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/FactoryMethod/StdoutLogger.php
Creational/FactoryMethod/StdoutLogger.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\FactoryMethod; class StdoutLogger implements Logger { public function log(string $message) { echo $message; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Creational/FactoryMethod/Tests/FactoryMethodTest.php
Creational/FactoryMethod/Tests/FactoryMethodTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Creational\FactoryMethod\Tests; use DesignPatterns\Creational\FactoryMethod\FileLogger; use DesignPatterns\Creational\FactoryMethod\FileLoggerFactory; use DesignPatterns\Creational\FactoryMethod\StdoutLogger; use DesignPatterns\Creational\FactoryMethod\StdoutLo...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Iterator/BookList.php
Behavioral/Iterator/BookList.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Iterator; use Countable; use Iterator; class BookList implements Countable, Iterator { /** * @var Book[] */ private array $books = []; private int $currentIndex = 0; public function addBook(Book $book) { $this-...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Iterator/Book.php
Behavioral/Iterator/Book.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Iterator; class Book { public function __construct(private string $title, private string $author) { } public function getAuthor(): string { return $this->author; } public function getTitle(): string { ...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Iterator/Tests/IteratorTest.php
Behavioral/Iterator/Tests/IteratorTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Iterator\Tests; use DesignPatterns\Behavioral\Iterator\Book; use DesignPatterns\Behavioral\Iterator\BookList; use PHPUnit\Framework\TestCase; class IteratorTest extends TestCase { public function testCanIterateOverBookList() { $bookL...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/ChainOfResponsibilities/Handler.php
Behavioral/ChainOfResponsibilities/Handler.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\ChainOfResponsibilities; use Psr\Http\Message\RequestInterface; abstract class Handler { public function __construct(private ?Handler $successor = null) { } /** * This approach by using a template method pattern ensures you tha...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/ChainOfResponsibilities/Responsible/SlowDatabaseHandler.php
Behavioral/ChainOfResponsibilities/Responsible/SlowDatabaseHandler.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible; use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler; use Psr\Http\Message\RequestInterface; class SlowDatabaseHandler extends Handler { protected function processing(RequestInterface $request): ?str...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/ChainOfResponsibilities/Responsible/HttpInMemoryCacheHandler.php
Behavioral/ChainOfResponsibilities/Responsible/HttpInMemoryCacheHandler.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible; use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler; use Psr\Http\Message\RequestInterface; class HttpInMemoryCacheHandler extends Handler { public function __construct(private array $data, ?Handler...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php
Behavioral/ChainOfResponsibilities/Tests/ChainTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Tests; use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler; use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\HttpInMemoryCacheHandler; use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsibl...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Strategy/Comparator.php
Behavioral/Strategy/Comparator.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Strategy; interface Comparator { /** * @param mixed $a * @param mixed $b */ public function compare($a, $b): int; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Strategy/Context.php
Behavioral/Strategy/Context.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Strategy; class Context { public function __construct(private Comparator $comparator) { } public function executeStrategy(array $elements): array { uasort($elements, [$this->comparator, 'compare']); return $eleme...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Strategy/DateComparator.php
Behavioral/Strategy/DateComparator.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Strategy; use DateTime; class DateComparator implements Comparator { public function compare($a, $b): int { $aDate = new DateTime($a['date']); $bDate = new DateTime($b['date']); return $aDate <=> $bDate; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Strategy/IdComparator.php
Behavioral/Strategy/IdComparator.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Strategy; class IdComparator implements Comparator { public function compare($a, $b): int { return $a['id'] <=> $b['id']; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Strategy/Tests/StrategyTest.php
Behavioral/Strategy/Tests/StrategyTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Strategy\Tests; use DesignPatterns\Behavioral\Strategy\Context; use DesignPatterns\Behavioral\Strategy\DateComparator; use DesignPatterns\Behavioral\Strategy\IdComparator; use PHPUnit\Framework\TestCase; class StrategyTest extends TestCase { pub...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Memento/State.php
Behavioral/Memento/State.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Memento; use InvalidArgumentException; class State implements \Stringable { public const STATE_CREATED = 'created'; public const STATE_OPENED = 'opened'; public const STATE_ASSIGNED = 'assigned'; public const STATE_CLOSED = 'closed';...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Memento/Ticket.php
Behavioral/Memento/Ticket.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Memento; /** * Ticket is the "Originator" in this implementation */ class Ticket { private State $currentState; public function __construct() { $this->currentState = new State(State::STATE_CREATED); } public function o...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Memento/Memento.php
Behavioral/Memento/Memento.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Memento; class Memento { public function __construct(private State $state) { } public function getState(): State { return $this->state; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Memento/Tests/MementoTest.php
Behavioral/Memento/Tests/MementoTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Memento\Tests; use DesignPatterns\Behavioral\Memento\State; use DesignPatterns\Behavioral\Memento\Ticket; use PHPUnit\Framework\TestCase; class MementoTest extends TestCase { public function testOpenTicketAssignAndSetBackToOpen() { $...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Visitor/RecordingVisitor.php
Behavioral/Visitor/RecordingVisitor.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Visitor; class RecordingVisitor implements RoleVisitor { /** * @var Role[] */ private array $visited = []; public function visitGroup(Group $role) { $this->visited[] = $role; } public function visitUser(Use...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Visitor/User.php
Behavioral/Visitor/User.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Visitor; class User implements Role { public function __construct(private string $name) { } public function getName(): string { return sprintf('User %s', $this->name); } public function accept(RoleVisitor $visito...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Visitor/RoleVisitor.php
Behavioral/Visitor/RoleVisitor.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Visitor; /** * Note: the visitor must not choose itself which method to * invoke, it is the visited object that makes this decision */ interface RoleVisitor { public function visitUser(User $role); public function visitGroup(Group $role);...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Visitor/Role.php
Behavioral/Visitor/Role.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Visitor; interface Role { public function accept(RoleVisitor $visitor); }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Visitor/Group.php
Behavioral/Visitor/Group.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Visitor; class Group implements Role { public function __construct(private string $name) { } public function getName(): string { return sprintf('Group: %s', $this->name); } public function accept(RoleVisitor $vis...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Visitor/Tests/VisitorTest.php
Behavioral/Visitor/Tests/VisitorTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Tests\Visitor\Tests; use DesignPatterns\Behavioral\Visitor\RecordingVisitor; use DesignPatterns\Behavioral\Visitor\User; use DesignPatterns\Behavioral\Visitor\Group; use DesignPatterns\Behavioral\Visitor\Role; use DesignPatterns\Behavioral\Visitor; use PHPUnit\...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/NullObject/PrintLogger.php
Behavioral/NullObject/PrintLogger.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\NullObject; class PrintLogger implements Logger { public function log(string $str) { echo $str; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/NullObject/Service.php
Behavioral/NullObject/Service.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\NullObject; class Service { public function __construct(private Logger $logger) { } /** * do something ... */ public function doSomething() { // notice here that you don't have to check if the logger is set ...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/NullObject/NullLogger.php
Behavioral/NullObject/NullLogger.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\NullObject; class NullLogger implements Logger { public function log(string $str) { // do nothing } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/NullObject/Logger.php
Behavioral/NullObject/Logger.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\NullObject; /** * Key feature: NullLogger must inherit from this interface like any other loggers */ interface Logger { public function log(string $str); }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/NullObject/Tests/LoggerTest.php
Behavioral/NullObject/Tests/LoggerTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\NullObject\Tests; use DesignPatterns\Behavioral\NullObject\NullLogger; use DesignPatterns\Behavioral\NullObject\PrintLogger; use DesignPatterns\Behavioral\NullObject\Service; use PHPUnit\Framework\TestCase; class LoggerTest extends TestCase { pu...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/State/OrderDone.php
Behavioral/State/OrderDone.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\State; class OrderDone implements StateOrder { public function proceedToNext(ContextOrder $context): void { // there is nothing more to do } public function toString(): string { return 'done'; } }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/State/ShippingOrder.php
Behavioral/State/ShippingOrder.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\State; class ShippingOrder implements StateOrder { public function proceedToNext(ContextOrder $context): void { $context->setState(new OrderDone()); } public function toString(): string { return 'shipped'; } }...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/State/ContextOrder.php
Behavioral/State/ContextOrder.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\State; class ContextOrder { private StateOrder $state; public static function create(): ContextOrder { $order = new self(); $order->state = new CreateOrder(); return $order; } public function setState(St...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/State/CreateOrder.php
Behavioral/State/CreateOrder.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\State; class CreateOrder implements StateOrder { public function proceedToNext(ContextOrder $context): void { $context->setState(new ShippingOrder()); } public function toString(): string { return 'created'; }...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/State/StateOrder.php
Behavioral/State/StateOrder.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\State; interface StateOrder { public function proceedToNext(ContextOrder $context): void; public function toString(): string; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/State/Tests/StateTest.php
Behavioral/State/Tests/StateTest.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\State\Tests; use DesignPatterns\Behavioral\State\ContextOrder; use PHPUnit\Framework\TestCase; class StateTest extends TestCase { public function testIsCreatedWithStateCreated(): void { $orderContext = ContextOrder::create(); ...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Specification/Specification.php
Behavioral/Specification/Specification.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Specification; interface Specification { public function isSatisfiedBy(Item $item): bool; }
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false
DesignPatternsPHP/DesignPatternsPHP
https://github.com/DesignPatternsPHP/DesignPatternsPHP/blob/54254e0f2a59e27280f81304bce9218e12f97a03/Behavioral/Specification/AndSpecification.php
Behavioral/Specification/AndSpecification.php
<?php declare(strict_types=1); namespace DesignPatterns\Behavioral\Specification; class AndSpecification implements Specification { /** * @var Specification[] */ private array $specifications; /** * @param Specification[] $specifications */ public function __construct(Specificati...
php
MIT
54254e0f2a59e27280f81304bce9218e12f97a03
2026-01-04T15:02:34.345104Z
false