-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
phparkitect.php
52 lines (46 loc) · 1.72 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
use Arkitect\ClassSet;
use Arkitect\CLI\Config;
use Arkitect\Expression\ForClasses\Extend;
use Arkitect\Expression\ForClasses\HaveNameMatching;
use Arkitect\Expression\ForClasses\IsFinal;
use Arkitect\Expression\ForClasses\NotDependsOnTheseNamespaces;
use Arkitect\Expression\ForClasses\ResideInOneOfTheseNamespaces;
use Arkitect\Rules\Rule;
use PhpSpec\ObjectBehavior;
return static function (Config $config): void {
$specSet = ClassSet::fromDir(__DIR__ . '{/spec}');
$config->add(
$specSet,
Rule::allClasses()
->that(new Extend(ObjectBehavior::class))
->should(new HaveNameMatching('*Spec'))
->because('This is a convention from PHPSpec')
,
Rule::allClasses()
->that(new Extend(ObjectBehavior::class))
->should(new IsFinal())
->because('Specifications should not be extendable')
,
);
$architectureSet = ClassSet::fromDir(__DIR__ . '{/src}');
$config->add(
$architectureSet,
Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('Sylius\PriceHistory\Domain'))
->should(new NotDependsOnTheseNamespaces(
'Sylius\PriceHistory\Application',
'Sylius\PriceHistory\Infrastructure',
))
->because('Domain should not depend on Application or Infrastructure')
,
Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('Sylius\PriceHistory\Application'))
->should(new NotDependsOnTheseNamespaces(
'Sylius\PriceHistory\Infrastructure',
))
->because('Application should not depend on Infrastructure')
,
);
};