Test Failed
Pull Request — master (#73)
by Chris
02:17
created

IsPrivate::filter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
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\TicketAvailability\Filters;
10
11
12
use ConferenceTools\Tickets\Domain\ReadModel\TicketCounts\TicketCounter;
13
use ConferenceTools\Tickets\Domain\Service\Configuration;
14
use Doctrine\Common\Collections\Collection;
15
16 View Code Duplication
class IsPrivate implements FilterInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * @var Configuration
20
     */
21
    private $configuration;
22
23
    public function __construct(Configuration $configuration)
24
    {
25
        $this->configuration = $configuration;
26
    }
27
28
    public function filter(Collection $tickets): Collection
29
    {
30
        $configuration = $this->configuration;
31
        $p = function (TicketCounter $ticket) use ($configuration) {
32
            $metadata = $configuration->getTicketMetadata($ticket->getTicketType()->getIdentifier());
33
            return !$metadata->isPrivateTicket();
34
        };
35
        return $tickets->filter($p);
36
    }
37
}