Passed
Push — master ( 6afdcd...dc022a )
by Hirofumi
05:03
created

NotificationDeduplicationKeySpecification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 36
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isSatisfiedBy() 0 8 2
A whereExpression() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shippinno\Notification\Domain\Model;
5
6
use Tanigami\Specification\Specification;
7
8
class NotificationDeduplicationKeySpecification extends Specification
9
{
10
    /**
11
     * @var DeduplicationKey
12
     */
13
    private $deduplicationKey;
14
15
    /**
16
     * @param DeduplicationKey $deduplicationKey
17
     */
18 3
    public function __construct(DeduplicationKey $deduplicationKey)
19
    {
20 3
        $this->deduplicationKey = $deduplicationKey;
21 3
    }
22
23
    /**
24
     * @param Notification $notification
25
     * @return bool
26
     */
27 1
    public function isSatisfiedBy($notification): bool
28
    {
29 1
        if (is_null($notification->deduplicationKey())) {
30 1
            return false;
31
        }
32
33 1
        return $notification->deduplicationKey()->equals($this->deduplicationKey);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 2
    public function whereExpression(string $alias): string
40
    {
41 2
        return sprintf("%s.deduplicationKey = '%s'", $alias, $this->deduplicationKey->key());
42
    }
43
}
44