| @@ 241-255 (lines=15) @@ | ||
| 238 | * @param Card|\Closure|null $card |
|
| 239 | * @return $this |
|
| 240 | */ |
|
| 241 | public function card($card) |
|
| 242 | { |
|
| 243 | if ($card instanceof Card) { |
|
| 244 | $this->card = $card; |
|
| 245 | ||
| 246 | return $this; |
|
| 247 | } |
|
| 248 | ||
| 249 | if ($card instanceof \Closure) { |
|
| 250 | $card($new = new Card()); |
|
| 251 | $this->card = $new; |
|
| 252 | ||
| 253 | return $this; |
|
| 254 | } |
|
| 255 | ||
| 256 | throw new \InvalidArgumentException('Invalid Card type. Expected '.Card::class.' or '.\Closure::class.'.'); |
|
| 257 | } |
|
| 258 | ||
| @@ 343-357 (lines=15) @@ | ||
| 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('Invalid attribute type. Expected '.CardAttribute::class.' or '.\Closure::class.'.'); |
|
| 359 | } |
|
| 360 | ||