Command   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractType() 0 20 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Domain Policy Class
6
 * @package Ticaje_BookingApi
7
 * @author Hector Luis Barrientos <[email protected]>
8
 */
9
10
namespace Ticaje\BookingApi\Domain\Policies\Calendar\Disabling\CQRS;
11
12
/**
13
 * Class Command
14
 * @package Ticaje\BookingApi\Domain\Policies\Calendar\Disabling\CQRS
15
 */
16
class Command implements CommandSignature
17
{
18
    /**
19
     * @inheritDoc
20
     */
21
    public function extractType(array $input): array
22
    {
23
        $result = [
24
            'single' => (function () use ($input) {
25
                $result['rule'] = json_encode(['date' => $input['date']]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$result was never initialized. Although not strictly required by PHP, it is generally a good practice to add $result = array(); before regardless.
Loading history...
26
                $result['period'] = $input['period'];
27
                return $result;
28
            }),
29
            'period' => (function () use ($input) {
30
                $result['rule'] = json_encode(['from' => $input['disableFrom'], 'to' => $input['disableTo']]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$result was never initialized. Although not strictly required by PHP, it is generally a good practice to add $result = array(); before regardless.
Loading history...
31
                $result['period'] = $input['period'];
32
                return $result;
33
            }),
34
            'recurrent_day' => (function () use ($input) {
35
                $result['rule'] = json_encode(['dayOfWeek' => $input['dayOfWeek']]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$result was never initialized. Although not strictly required by PHP, it is generally a good practice to add $result = array(); before regardless.
Loading history...
36
                $result['period'] = $input['period'];
37
                return $result;
38
            })
39
        ];
40
        return $result[$input['period']]();
41
    }
42
}
43