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

whereExpression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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