Total Complexity | 6 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
10 | trait PassesModes |
||
11 | { |
||
12 | /** |
||
13 | * The passed modes. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | private $modes; |
||
18 | |||
19 | /** |
||
20 | * Parse and retrieve the modes. |
||
21 | * |
||
22 | * @return array |
||
23 | */ |
||
24 | protected function modes(): array |
||
25 | { |
||
26 | $modes = [ |
||
27 | 'passwords' => $this->option('passwords'), |
||
|
|||
28 | 'users' => $this->option('users'), |
||
29 | ]; |
||
30 | |||
31 | return $this->modes = array_filter($modes); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Checks whether user has a mode. |
||
36 | * |
||
37 | * @param string $mode |
||
38 | * |
||
39 | * @return bool |
||
40 | */ |
||
41 | protected function hasMode(string $mode): bool |
||
42 | { |
||
43 | return array_key_exists($mode, $this->modes()); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Checks whether any mode is passed. |
||
48 | * |
||
49 | * @return bool |
||
50 | */ |
||
51 | protected function hasModes(): bool |
||
52 | { |
||
53 | return count($this->modes()) > 0; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Write modes to the output. |
||
58 | * |
||
59 | * @param array $modes |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | protected function displayModes(array $modes = null) |
||
69 | } |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Format the modes to a string. |
||
74 | * |
||
75 | * @param array $modes |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | protected function formatModes(array $modes): string |
||
82 | } |
||
83 | } |