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 */
|
/** @noinspection ForgottenDebugOutputInspection */
|
||||||
dump($draft);
|
dump($draft);
|
||||||
}
|
}
|
||||||
|
?><img class="diagram" src="/assets/img/diagrams/prototype.png" alt="Adapter DEsign Pattern Diagram"><?php
|
||||||
client();
|
client();
|
||||||
|
@ -16,7 +16,7 @@ use Pattern\Creational\{Singleton\Single, Singleton\Singleton};
|
|||||||
*
|
*
|
||||||
* @noinspection ForgottenDebugOutputInspection
|
* @noinspection ForgottenDebugOutputInspection
|
||||||
*/
|
*/
|
||||||
function clientCode(): void
|
function client(): void
|
||||||
{
|
{
|
||||||
$output = [
|
$output = [
|
||||||
'where' => trace(),
|
'where' => trace(),
|
||||||
@ -36,7 +36,8 @@ function clientCode(): void
|
|||||||
dump($output, $output['s1']->getValue(), $output['s2']->getValue());
|
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 = Single::getInstance('from subclass');
|
||||||
$single->setValue('value set from Single::class')->childish();
|
$single->setValue('value set from Single::class')->childish();
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "8.3.*",
|
"php": "8.3.*",
|
||||||
"ext-simplexml": "*",
|
"ext-simplexml": "*"
|
||||||
"ext-yaml": "*"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^3.76"
|
"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",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "8d4ed5a63e8da7821980256ec54097f7",
|
"content-hash": "15fcc4c375fa23daddd63652d90fdeab",
|
||||||
"packages": [],
|
"packages": [],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
@ -2544,7 +2544,10 @@
|
|||||||
"stability-flags": {},
|
"stability-flags": {},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {},
|
"platform": {
|
||||||
|
"php": "8.3.*",
|
||||||
|
"ext-simplexml": "*"
|
||||||
|
},
|
||||||
"platform-dev": {},
|
"platform-dev": {},
|
||||||
"plugin-api-version": "2.6.0"
|
"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 |
@ -41,25 +41,28 @@ require '../src/helpers.php';
|
|||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
max-height: 92dvh;
|
max-height: 92dvh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
background-color: attr(data-color type(<color>), #eef0f0);
|
background-color: attr(data-color type(< color >), #eef0f0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre, code {
|
pre, code {
|
||||||
font-family: Consolas, monospace;
|
font-family: Consolas, monospace;
|
||||||
font-size: 1.125rem;
|
font-size: 1.125rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.diagram {
|
img.diagram {
|
||||||
|
display: block;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
margin: 0 auto 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.et {
|
.et {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: .5rem;
|
bottom: .5rem;
|
||||||
left: .5rem;
|
right: .5rem;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
@ -68,12 +71,10 @@ require '../src/helpers.php';
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main data-color="#eef0f0">
|
<main data-color="#eef0f0">
|
||||||
<?php require '../src/router.php' ?>
|
<?php
|
||||||
|
require '../src/router.php' ?>
|
||||||
</main>
|
</main>
|
||||||
<div class="et">ET: <?= (microtime(true) - $time_start) ?> secs</div>
|
<div class="et">ET: <?= (microtime(true) - $time_start) ?> secs</div>
|
||||||
<script>hljs.highlightAll()</script>
|
<script>hljs.highlightAll()</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace Pattern\Creational\Singleton;
|
namespace RefactoringGuru\Builder\RealWorld\singleton;
|
||||||
|
|
||||||
interface Loggable
|
interface Loggable
|
||||||
{
|
{
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace Pattern\Creational\Singleton;
|
namespace RefactoringGuru\Builder\RealWorld\singleton;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user