-
Notifications
You must be signed in to change notification settings - Fork 0
/
phparkitect.php
38 lines (30 loc) · 1.38 KB
/
phparkitect.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
<?php
declare(strict_types=1);
use Arkitect\ClassSet;
use Arkitect\CLI\Config;
use Arkitect\Expression\ForClasses\DependsOnlyOnTheseNamespaces;
use Arkitect\Expression\ForClasses\HaveNameMatching;
use Arkitect\Expression\ForClasses\NotHaveDependencyOutsideNamespace;
use Arkitect\Expression\ForClasses\ResideInOneOfTheseNamespaces;
use Arkitect\Rules\Rule;
return static function(Config $config): void
{
$classSet = ClassSet::fromDir(__DIR__ . '/src');
$r1 = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Catalog\Application\Service'))
->should(new HaveNameMatching('*Service'))
->because("we want uniform naming");
$r2 = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Catalog\Domain'))
->should(new NotHaveDependencyOutsideNamespace('App\Catalog\Domain'))
->because('domain should not have external dependencies');
$r3 = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Catalog\Application'))
->should(new DependsOnlyOnTheseNamespaces('App\Catalog\Domain'))
->because('we love exagonal architecture');
$r4 = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Order\*'))
->should(new DependsOnlyOnTheseNamespaces('App\Order\*'))
->because('we want to preseve contexts');
$config->add($classSet, $r1, $r2, $r3, $r4);
};