| @@ 479-510 (lines=32) @@ | ||
| 476 | /**  | 
                                |
| 477 | * @return ClassGenerator  | 
                                |
| 478 | */  | 
                                |
| 479 | public function generateMagicGet(): ClassGenerator  | 
                                |
| 480 |     { | 
                                |
| 481 | $cases = '';  | 
                                |
| 482 | ||
| 483 | /** @var Property $property */  | 
                                |
| 484 |         foreach ($this->class->getProperties() as $property) { | 
                                |
| 485 |             $getter = static::camelCase('get_' . $property->getName()); | 
                                |
| 486 | ||
| 487 |             try { | 
                                |
| 488 | $this->class->getMethod($getter);  | 
                                |
| 489 |             } catch (InvalidArgumentException $e) { | 
                                |
| 490 | continue;  | 
                                |
| 491 | }  | 
                                |
| 492 | ||
| 493 | $cases .=  | 
                                |
| 494 | ' case \'' . substr($property->getName(), 2, -2) . '\':' . PHP_EOL .  | 
                                |
| 495 | ' return $this->' . $getter . '();' . PHP_EOL . PHP_EOL;  | 
                                |
| 496 | }  | 
                                |
| 497 | ||
| 498 | $this->class  | 
                                |
| 499 |             ->addMethod('__get') | 
                                |
| 500 | ->addComment(  | 
                                |
| 501 | '@inheritDoc'  | 
                                |
| 502 | )->setBody(  | 
                                |
| 503 |                 'switch ($name) {' . PHP_EOL . | 
                                |
| 504 | $cases .  | 
                                |
| 505 | ' default:' . PHP_EOL .  | 
                                |
| 506 | ' return null;' . PHP_EOL .  | 
                                |
| 507 | '}'  | 
                                |
| 508 |             )->addParameter('name'); | 
                                |
| 509 | return $this;  | 
                                |
| 510 | }  | 
                                |
| 511 | ||
| 512 | /**  | 
                                |
| 513 | * @return ClassGenerator  | 
                                |
| @@ 556-587 (lines=32) @@ | ||
| 553 | /**  | 
                                |
| 554 | * @return ClassGenerator  | 
                                |
| 555 | */  | 
                                |
| 556 | public function generateMagicIsset(): ClassGenerator  | 
                                |
| 557 |     { | 
                                |
| 558 | $cases = '';  | 
                                |
| 559 | ||
| 560 | /** @var Property $property */  | 
                                |
| 561 |         foreach ($this->class->getProperties() as $property) { | 
                                |
| 562 |             $isset = static::camelCase('isset_' . $property->getName()); | 
                                |
| 563 | ||
| 564 |             try { | 
                                |
| 565 | $this->class->getMethod($isset);  | 
                                |
| 566 |             } catch (InvalidArgumentException $e) { | 
                                |
| 567 | continue;  | 
                                |
| 568 | }  | 
                                |
| 569 | ||
| 570 | $cases .=  | 
                                |
| 571 | ' case \'' . substr($property->getName(), 2, -2) . '\':' . PHP_EOL .  | 
                                |
| 572 | ' return $this->' . $isset . '();' . PHP_EOL . PHP_EOL;  | 
                                |
| 573 | }  | 
                                |
| 574 | ||
| 575 | $this->class  | 
                                |
| 576 |             ->addMethod('__isset') | 
                                |
| 577 | ->addComment(  | 
                                |
| 578 | '@inheritDoc'  | 
                                |
| 579 | )->setBody(  | 
                                |
| 580 |                 'switch ($name) {' . PHP_EOL . | 
                                |
| 581 | $cases .  | 
                                |
| 582 | ' default:' . PHP_EOL .  | 
                                |
| 583 | ' return false;' . PHP_EOL .  | 
                                |
| 584 | '}'  | 
                                |
| 585 |             )->addParameter('name'); | 
                                |
| 586 | return $this;  | 
                                |
| 587 | }  | 
                                |
| 588 | ||
| 589 | /**  | 
                                |
| 590 | * @return ClassGenerator  | 
                                |
| @@ 592-623 (lines=32) @@ | ||
| 589 | /**  | 
                                |
| 590 | * @return ClassGenerator  | 
                                |
| 591 | */  | 
                                |
| 592 | public function generateMagicUnset(): ClassGenerator  | 
                                |
| 593 |     { | 
                                |
| 594 | $cases = '';  | 
                                |
| 595 | ||
| 596 | /** @var Property $property */  | 
                                |
| 597 |         foreach ($this->class->getProperties() as $property) { | 
                                |
| 598 |             $unset = static::camelCase('unset_' . $property->getName()); | 
                                |
| 599 | ||
| 600 |             try { | 
                                |
| 601 | $this->class->getMethod($unset);  | 
                                |
| 602 |             } catch (InvalidArgumentException $e) { | 
                                |
| 603 | continue;  | 
                                |
| 604 | }  | 
                                |
| 605 | ||
| 606 | $cases .=  | 
                                |
| 607 | ' case \'' . substr($property->getName(), 2, -2) . '\':' . PHP_EOL .  | 
                                |
| 608 | ' return $this->' . $unset . '();' . PHP_EOL . PHP_EOL;  | 
                                |
| 609 | }  | 
                                |
| 610 | ||
| 611 | $this->class  | 
                                |
| 612 |             ->addMethod('__unset') | 
                                |
| 613 | ->addComment(  | 
                                |
| 614 | '@inheritDoc'  | 
                                |
| 615 | )->setBody(  | 
                                |
| 616 |                 'switch ($name) {' . PHP_EOL . | 
                                |
| 617 | $cases .  | 
                                |
| 618 | ' default:' . PHP_EOL .  | 
                                |
| 619 | ' return $this;' . PHP_EOL .  | 
                                |
| 620 | '}'  | 
                                |
| 621 |             )->addParameter('name'); | 
                                |
| 622 | return $this;  | 
                                |
| 623 | }  | 
                                |
| 624 | }  | 
                                |