-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolid_runner
More file actions
executable file
·49 lines (39 loc) · 1.5 KB
/
solid_runner
File metadata and controls
executable file
·49 lines (39 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env php
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
/**
* Single-responsibility Principle (SRP):
* A class should have one and only one reason to change, meaning that a class should have only one job.
*/
/**
* Open-closed Principle (OCP):
* Objects or entities should be open for extension but closed for modification.
*/
/**
* Liskov Substitution Principle (LSP):
* Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.
* This means that every subclass or derived class should be substitutable for their base or parent class.
*/
/**
* Interface Segregation Principle (ISP):
* A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.
*/
/**
* Dependency Inversion Principle (DIP):
* Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend
* on the low-level module, but they should depend on abstractions.
*/
$runners = [
'SRP' => App\SingleResponsibility\Runner::class,
'OCP' => App\OpenClosed\Runner::class,
'LSP' => App\LiskovSubstitution\Runner::class,
'ISP' => App\InterfaceSegregation\Runner::class,
'DIP' => App\DependencyInversion\Runner::class,
];
if(!isset($argv[1]) || !in_array($argv[1], array_keys($runners))){
return;
}
$runner = new $runners[$argv[1]];
$runner->problemRun();
$runner->solutionRun();