Add Litlab
This commit is contained in:
parent
1cf6e3d7d2
commit
dabbf541dc
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM php:8.3-cli-alpine3.22
|
||||
|
||||
ENTRYPOINT ["php", "-S", "localhost:8008", "-t", "public/"]
|
12
code/decorator.php
Normal file
12
code/decorator.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-04
|
||||
* @time: 10:39
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
dump('Decorator');
|
@ -36,5 +36,5 @@ function client(): void
|
||||
/** @noinspection ForgottenDebugOutputInspection */
|
||||
dump($draft);
|
||||
}
|
||||
|
||||
?><img class="diagram" src="/assets/img/diagrams/prototype.png" alt="Adapter DEsign Pattern Diagram"><?php
|
||||
client();
|
||||
|
@ -16,7 +16,7 @@ use Pattern\Creational\{Singleton\Single, Singleton\Singleton};
|
||||
*
|
||||
* @noinspection ForgottenDebugOutputInspection
|
||||
*/
|
||||
function clientCode(): void
|
||||
function client(): void
|
||||
{
|
||||
$output = [
|
||||
'where' => trace(),
|
||||
@ -36,7 +36,8 @@ function clientCode(): void
|
||||
dump($output, $output['s1']->getValue(), $output['s2']->getValue());
|
||||
}
|
||||
|
||||
clientCode();
|
||||
?><img class="diagram" src="/assets/img/diagrams/singleton.png" alt="Adapter DEsign Pattern Diagram"><?php
|
||||
client();
|
||||
|
||||
$single = Single::getInstance('from subclass');
|
||||
$single->setValue('value set from Single::class')->childish();
|
||||
|
@ -13,8 +13,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "8.3.*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-yaml": "*"
|
||||
"ext-simplexml": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.76"
|
||||
|
7
composer.lock
generated
7
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8d4ed5a63e8da7821980256ec54097f7",
|
||||
"content-hash": "15fcc4c375fa23daddd63652d90fdeab",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
@ -2544,7 +2544,10 @@
|
||||
"stability-flags": {},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {},
|
||||
"platform": {
|
||||
"php": "8.3.*",
|
||||
"ext-simplexml": "*"
|
||||
},
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
BIN
public/assets/img/diagrams/prototype.png
Normal file
BIN
public/assets/img/diagrams/prototype.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
BIN
public/assets/img/diagrams/singleton.png
Normal file
BIN
public/assets/img/diagrams/singleton.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -48,18 +48,21 @@ require '../src/helpers.php';
|
||||
font-family: Consolas, monospace;
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
img.diagram {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin: 0 auto 1rem;
|
||||
}
|
||||
|
||||
.et {
|
||||
position: absolute;
|
||||
top: .5rem;
|
||||
left: .5rem;
|
||||
bottom: .5rem;
|
||||
right: .5rem;
|
||||
font-size: small;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
@ -68,12 +71,10 @@ require '../src/helpers.php';
|
||||
</head>
|
||||
<body>
|
||||
<main data-color="#eef0f0">
|
||||
<?php require '../src/router.php' ?>
|
||||
<?php
|
||||
require '../src/router.php' ?>
|
||||
</main>
|
||||
<div class="et">ET: <?= (microtime(true) - $time_start) ?> secs</div>
|
||||
<script>hljs.highlightAll()</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
22
src/Pattern/Structural/Decorator/BorderDecorator.php
Normal file
22
src/Pattern/Structural/Decorator/BorderDecorator.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-04
|
||||
* @time: 10:42
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Structural\Decorator;
|
||||
|
||||
class BorderDecorator implements ShapeInterface
|
||||
{
|
||||
public function __construct(private ShapeInterface $shape) {}
|
||||
|
||||
public function draw(): void
|
||||
{
|
||||
echo '<div style="width: 8rem; height: 8rem; border: .5rem solid orange"></div>';
|
||||
}
|
||||
}
|
20
src/Pattern/Structural/Decorator/Circle.php
Normal file
20
src/Pattern/Structural/Decorator/Circle.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-04
|
||||
* @time: 10:41
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Structural\Decorator;
|
||||
|
||||
class Circle implements ShapeInterface
|
||||
{
|
||||
public function draw(): void
|
||||
{
|
||||
// TODO: Implement draw() method.
|
||||
}
|
||||
}
|
22
src/Pattern/Structural/Decorator/EmailDecorator.php
Normal file
22
src/Pattern/Structural/Decorator/EmailDecorator.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-04
|
||||
* @time: 10:43
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Structural\Decorator;
|
||||
|
||||
class EmailDecorator implements ShapeInterface
|
||||
{
|
||||
public function __construct(private ShapeInterface $shape) {}
|
||||
|
||||
public function draw(): void
|
||||
{
|
||||
// TODO: Implement draw() method.
|
||||
}
|
||||
}
|
17
src/Pattern/Structural/Decorator/ShapeInterface.php
Normal file
17
src/Pattern/Structural/Decorator/ShapeInterface.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-04
|
||||
* @time: 10:38
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Structural\Decorator;
|
||||
|
||||
interface ShapeInterface
|
||||
{
|
||||
public function draw(): void;
|
||||
}
|
22
src/Pattern/Structural/Decorator/SmileDecorator.php
Normal file
22
src/Pattern/Structural/Decorator/SmileDecorator.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-04
|
||||
* @time: 10:47
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Structural\Decorator;
|
||||
|
||||
class SmileDecorator implements ShapeInterface
|
||||
{
|
||||
public function __construct(private ShapeInterface $shape) {}
|
||||
|
||||
public function draw(): void
|
||||
{
|
||||
// TODO: Implement draw() method.
|
||||
}
|
||||
}
|
20
src/Pattern/Structural/Decorator/Square.php
Normal file
20
src/Pattern/Structural/Decorator/Square.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: patterns
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2025-07-04
|
||||
* @time: 10:41
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Structural\Decorator;
|
||||
|
||||
class Square implements ShapeInterface
|
||||
{
|
||||
public function draw(): void
|
||||
{
|
||||
// TODO: Implement draw() method.
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\Singleton;
|
||||
namespace RefactoringGuru\Builder\RealWorld\singleton;
|
||||
|
||||
interface Loggable
|
||||
{
|
@ -12,7 +12,7 @@
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Pattern\Creational\Singleton;
|
||||
namespace RefactoringGuru\Builder\RealWorld\singleton;
|
||||
|
||||
use RuntimeException;
|
||||
|
Loading…
Reference in New Issue
Block a user