-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
phparkitect-stub.php
39 lines (30 loc) · 1.5 KB
/
phparkitect-stub.php
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
<?php
declare(strict_types=1);
use Arkitect\ClassSet;
use Arkitect\CLI\Config;
use Arkitect\Expression\ForClasses\HaveNameMatching;
use Arkitect\Expression\ForClasses\ResideInOneOfTheseNamespaces;
use Arkitect\RuleBuilders\Architecture\Architecture;
use Arkitect\Rules\Rule;
return static function (Config $config): void {
$classSet = ClassSet::fromDir(__DIR__.'/src');
$layeredArchitectureRules = Architecture::withComponents()
->component('Controller')->definedBy('App\Controller\*')
->component('Service')->definedBy('App\Service\*')
->component('Repository')->definedBy('App\Repository\*')
->component('Entity')->definedBy('App\Entity\*')
->where('Controller')->mayDependOnComponents('Service', 'Entity')
->where('Service')->mayDependOnComponents('Repository', 'Entity')
->where('Repository')->mayDependOnComponents('Entity')
->where('Entity')->shouldNotDependOnAnyComponent()
->rules();
$serviceNamingRule = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Service'))
->should(new HaveNameMatching('*Service'))
->because('we want uniform naming for services');
$repositoryNamingRule = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Repository'))
->should(new HaveNameMatching('*Repository'))
->because('we want uniform naming for repositories');
$config->add($classSet, $serviceNamingRule, $repositoryNamingRule, ...$layeredArchitectureRules);
};