StrategyDefinition   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 61
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getGenerator() 0 4 1
A getGeneratorMethod() 0 4 1
A getVoter() 0 4 1
A getVoterMethod() 0 4 1
A hasVoter() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Explicit Architecture POC,
7
 * which is created on top of the Symfony Demo application.
8
 *
9
 * (c) Herberto Graça <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Acme\App\Infrastructure\Notification;
16
17
/**
18
 * @author Herberto Graca <[email protected]>
19
 * @author Nicolae Nichifor
20
 */
21
final class StrategyDefinition
22
{
23
    private const VOTER_DEFAULT_METHOD = 'vote';
24
25
    /**
26
     * @var object
27
     */
28
    private $generator;
29
30
    /**
31
     * @var string
32
     */
33
    private $generatorMethod;
34
35
    /**
36
     * @var object|null
37
     */
38
    private $voter;
39
40
    /**
41
     * @var string|null
42
     */
43
    private $voterMethod;
44
45
    public function __construct(
46
        $generator,
47
        string $generatorMethod,
48
        $voter = null,
49
        ?string $voterMethod = self::VOTER_DEFAULT_METHOD
50
    ) {
51
        $this->generator = $generator;
52
        $this->generatorMethod = $generatorMethod;
53
        $this->voter = $voter;
54
        $this->voterMethod = $voterMethod ?? self::VOTER_DEFAULT_METHOD;
55
    }
56
57
    public function getGenerator()
58
    {
59
        return $this->generator;
60
    }
61
62
    public function getGeneratorMethod(): string
63
    {
64
        return $this->generatorMethod;
65
    }
66
67
    public function getVoter()
68
    {
69
        return $this->voter;
70
    }
71
72
    public function getVoterMethod(): string
73
    {
74
        return $this->voterMethod;
75
    }
76
77
    public function hasVoter(): bool
78
    {
79
        return $this->voter !== null;
80
    }
81
}
82