|
3 | 3 | namespace LaravelEnso\Tables\Services\Template\Validators\Columns; |
4 | 4 |
|
5 | 5 | use Illuminate\Support\Collection; |
| 6 | +use LaravelEnso\Enums\Contracts\Select as Contract; |
6 | 7 | use LaravelEnso\Enums\Services\Enum; |
7 | | -use LaravelEnso\Enums\Traits\Select; |
8 | 8 | use LaravelEnso\Helpers\Services\Obj; |
9 | 9 | use LaravelEnso\Tables\Attributes\Column as Attributes; |
10 | 10 | use LaravelEnso\Tables\Attributes\Number; |
@@ -112,44 +112,40 @@ private function tooltip(): void |
112 | 112 | private function missingClass(string $attribute): bool |
113 | 113 | { |
114 | 114 | return $this->column->has($attribute) |
115 | | - && !class_exists($this->column->get($attribute)); |
| 115 | + && ! class_exists($this->column->get($attribute)); |
116 | 116 | } |
117 | 117 |
|
118 | 118 | public function enumNotFound(): bool |
119 | 119 | { |
120 | | - return !class_exists($this->column->get('enum')) |
121 | | - && !enum_exists($this->column->get('enum')); |
| 120 | + return ! class_exists($this->column->get('enum')) |
| 121 | + && ! enum_exists($this->column->get('enum')); |
122 | 122 | } |
123 | 123 |
|
124 | 124 | public function invalidEnum(): bool |
125 | 125 | { |
126 | | - $enum = $this->column->get('enum'); |
127 | | - |
128 | | - if (enum_exists($enum)) { |
129 | | - $traits = (new ReflectionEnum($enum))->getTraits(); |
130 | | - |
131 | | - return !in_array(Select::class, array_keys($traits)); |
132 | | - } else { |
133 | | - return !(new ReflectionClass($enum))->isSubclassOf(Enum::class); |
134 | | - } |
| 126 | + return enum_exists($this->column->get('enum')) |
| 127 | + ? ! (new ReflectionEnum($this->column->get('enum'))) |
| 128 | + ->implementsInterface(Contract::class) |
| 129 | + : ! (new ReflectionClass($$this->column->get('enum'))) |
| 130 | + ->isSubclassOf(Enum::class); |
135 | 131 | } |
136 | 132 |
|
137 | 133 | private function invalidString(string $attribute): bool |
138 | 134 | { |
139 | 135 | return $this->column->has($attribute) |
140 | | - && !is_string($this->column->get($attribute)); |
| 136 | + && ! is_string($this->column->get($attribute)); |
141 | 137 | } |
142 | 138 |
|
143 | 139 | private function invalidObject(string $attribute): bool //TODO can be aggregated with invalidAttributes |
144 | 140 | { |
145 | 141 | return $this->column->has($attribute) |
146 | | - && !is_object($this->column->get($attribute)); |
| 142 | + && ! is_object($this->column->get($attribute)); |
147 | 143 | } |
148 | 144 |
|
149 | 145 | private function invalidAttribute(string $attribute, array $allowed): bool |
150 | 146 | { |
151 | 147 | return $this->column->has($attribute) |
152 | | - && !in_array($this->column->get($attribute), $allowed); |
| 148 | + && ! in_array($this->column->get($attribute), $allowed); |
153 | 149 | } |
154 | 150 |
|
155 | 151 | private function invalidAttributes(string $attribute, array $allowed): bool |
|
0 commit comments