Watchman   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A passBuilder() 0 3 1
A isSupported() 0 8 2
1
<?php
2
/**
3
 *
4
 * This file is part of the Aggrego.
5
 * (c) Tomasz Kunicki <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
declare(strict_types = 1);
13
14
namespace Aggrego\BasicBlockDomainProfile\Domain\Profile\BoardConstruction;
15
16
use Aggrego\BasicBlockDomainProfile\Domain\Profile\Factory;
17
use Aggrego\Domain\Profile\BoardConstruction\Builder as DomainBuilder;
18
use Aggrego\Domain\Profile\BoardConstruction\Watchman as DomainWatchman;
19
use Aggrego\Domain\Profile\Profile;
20
use Assert\Assertion;
21
use Assert\InvalidArgumentException;
22
23
class Watchman implements DomainWatchman
24
{
25
    public function isSupported(Profile $profile): bool
26
    {
27
        try {
28
            Assertion::regex($profile->getVersion(), '~^([0-9]+\.{0,1})+$~');
29
        } catch (InvalidArgumentException $e) {
30
            return false;
31
        }
32
        return $profile->getName() === Factory::PROFILE_NAME;
33
    }
34
35
    public function passBuilder(Profile $profile): DomainBuilder
36
    {
37
        return new Builder(Factory::factory($profile->getVersion()));
38
    }
39
}
40