| @@ 343-359 (lines=17) @@ | ||
| 340 | * @param CardAttribute|Closure $attribute |
|
| 341 | * @return $this |
|
| 342 | */ |
|
| 343 | public function addAttribute($attribute) |
|
| 344 | { |
|
| 345 | if ($attribute instanceof CardAttribute) { |
|
| 346 | $this->attributes[] = $attribute; |
|
| 347 | ||
| 348 | return $this; |
|
| 349 | } |
|
| 350 | ||
| 351 | if ($attribute instanceof Closure) { |
|
| 352 | $attribute($new = new CardAttribute()); |
|
| 353 | $this->attributes[] = $new; |
|
| 354 | ||
| 355 | return $this; |
|
| 356 | } |
|
| 357 | ||
| 358 | throw new InvalidArgumentException( |
|
| 359 | 'Invalid attribute type. Expected '.CardAttribute::class.' or '.Closure::class.'.' |
|
| 360 | ); |
|
| 361 | } |
|
| 362 | ||
| @@ 244-260 (lines=17) @@ | ||
| 241 | * @param Card|Closure|null $card |
|
| 242 | * @return $this |
|
| 243 | */ |
|
| 244 | public function card($card) |
|
| 245 | { |
|
| 246 | if ($card instanceof Card) { |
|
| 247 | $this->card = $card; |
|
| 248 | ||
| 249 | return $this; |
|
| 250 | } |
|
| 251 | ||
| 252 | if ($card instanceof Closure) { |
|
| 253 | $card($new = new Card()); |
|
| 254 | $this->card = $new; |
|
| 255 | ||
| 256 | return $this; |
|
| 257 | } |
|
| 258 | ||
| 259 | throw new InvalidArgumentException( |
|
| 260 | 'Invalid Card type. Expected '.Card::class.' or '.Closure::class.'.' |
|
| 261 | ); |
|
| 262 | } |
|
| 263 | ||