Total Complexity | 7 |
Total Lines | 82 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class ShowColumn |
||
18 | { |
||
19 | /** @var string */ |
||
20 | private $field; |
||
21 | |||
22 | /** @var string */ |
||
23 | private $type; |
||
24 | |||
25 | /** @var string */ |
||
26 | private $null; |
||
27 | |||
28 | /** @var string */ |
||
29 | private $key; |
||
30 | |||
31 | /** @var string|null */ |
||
32 | private $default; |
||
33 | |||
34 | /** @var string */ |
||
35 | private $extra; |
||
36 | |||
37 | public function __construct(stdClass $column) |
||
38 | { |
||
39 | // Convert column property to case insensitive |
||
40 | // Issue https://github.com/kitloong/laravel-migrations-generator/issues/34 |
||
41 | $lowerKey = (new Collection($column))->mapWithKeys(function ($item, $key) { |
||
42 | return [strtolower($key) => $item]; |
||
43 | }); |
||
44 | |||
45 | $this->field = $lowerKey['field']; |
||
46 | $this->type = $lowerKey['type']; |
||
47 | $this->null = $lowerKey['null']; |
||
48 | $this->key = $lowerKey['key']; |
||
49 | $this->default = $lowerKey['default']; |
||
50 | $this->extra = $lowerKey['extra']; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getField(): string |
||
57 | { |
||
58 | return $this->field; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getType(): string |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @return string |
||
71 | */ |
||
72 | public function getNull(): string |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getKey(): string |
||
81 | { |
||
82 | return $this->key; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return string|null |
||
87 | */ |
||
88 | public function getDefault(): ?string |
||
89 | { |
||
90 | return $this->default; |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getExtra(): string |
||
99 | } |
||
100 | } |
||
101 |