SlotNumbersForCarsWithColour::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
c 0
b 0
f 0
rs 9.6666
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
namespace Parking\Console\Command;
3
/**
4
 * Class SlotNumbersForCarsWithColour
5
 *
6
 * @author Rafael Queiroz <[email protected]>
7
 * @package Parking\Console\Command
8
 */
9 View Code Duplication
class SlotNumbersForCarsWithColour implements Command
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...
10
{
11
12
    /**
13
     * @var \Parking\Domain\Repository\ParkingRepository
14
     */
15
    private $repository;
16
17
    /**
18
     * SlotNumbersForCarsWithColour constructor.
19
     * @param \Parking\Domain\Repository\ParkingRepository $repository
20
     */
21
    public function __construct(\Parking\Domain\Repository\ParkingRepository $repository)
22
    {
23
        $this->repository = $repository;
24
    }
25
26
    /**
27
     * Execute method
28
     *
29
     * @param $input
30
     * @param $output
31
     * @return string
32
     */
33
    public function execute($input, $output)
34
    {
35
        $this->validate($input);
36
37
        $keys = $this->repository->getSlotKeysForCarsWithColour($input[0]);
38
        $output = implode(', ', $keys);
39
40
        return $output;
41
    }
42
43
    /**
44
     * Validate method
45
     *
46
     * @param $input
47
     * @throws \Exception
48
     */
49
    protected function validate($input)
50
    {
51
        if (!isset($input[0])) {
52
            throw new \Exception('You need pass a colour');
53
        }
54
    }
55
56
}