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

whereExpression()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Shippinno\Notification\Domain\Model;
5
6
use Tanigami\Specification\Specification;
7
8
class NotificationIsFailedSpecification extends Specification
9
{
10
    /**
11
     * @var bool
12
     */
13
    private $expectsToBeFailed;
14
15
    /**
16
     * @param bool $expectsToBeFailed
17
     */
18 3
    public function __construct(bool $expectsToBeFailed = true)
19
    {
20 3
        $this->expectsToBeFailed = $expectsToBeFailed;
21 3
    }
22
23
    /**
24
     * @param Notification $notification
25
     * @return bool
26
     */
27
    public function isSatisfiedBy($notification): bool
28
    {
29
        return $this->expectsToBeFailed === $notification->isFailed();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 3
    public function whereExpression(string $alias): string
36
    {
37 3
        return sprintf(
38 3
            $this->expectsToBeFailed
39 2
                ? '%s.failedAt IS NOT NULL'
40 3
                : '%s.failedAt IS NULL',
41 3
            $alias
42
        );
43
    }
44
}
45