DiscountByDate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
ccs 7
cts 10
cp 0.7
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A filter() 0 11 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: imhotek
5
 * Date: 15/11/17
6
 * Time: 16:57
7
 */
8
9
namespace ConferenceTools\Tickets\Domain\Service\Availability\Filters;
10
11
use ConferenceTools\Tickets\Domain\ReadModel\Counts\TicketCounter;
0 ignored issues
show
Bug introduced by
The type ConferenceTools\Tickets\...el\Counts\TicketCounter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use ConferenceTools\Tickets\Domain\Service\Configuration;
13
use ConferenceTools\Tickets\Domain\ValueObject\DiscountCode;
14
use Doctrine\Common\Collections\Collection;
15
16
/**
17
 * @TODO refactor this to use a single filter
18
 */
19
class DiscountByDate implements FilterInterface
20
{
21
    /**
22
     * @var Configuration
23
     */
24
    private $configuration;
25
26
    public function __construct(Configuration $configuration)
27
    {
28
        $this->configuration = $configuration;
29
    }
30
31 4
    public function filter(Collection $tickets): Collection
32
    {
33 4
        $configuration = $this->configuration;
34 4
        $today = new \DateTime();
35
36 4
        $p = function(DiscountCode $discountCode) use ($configuration, $today) {
37 4
            $metadata = $configuration->getDiscountCodeMetadata($discountCode->getCode());
38 4
            return $metadata->isAvailableOn($today);
39 4
        };
40
41
        return $tickets->filter($p);
42
    }
43
}