Passed
Push — master ( 1fece0...af95a9 )
by Hector Luis
03:59
created

Command::extractType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 1
dl 0
loc 20
rs 9.7998
c 0
b 0
f 0
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