| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 46 | 7 | public function toString() { |
|
| 47 | 7 | if ( empty( $this->getName() ) ) { |
|
| 48 | 1 | throw new Exception( 'View must have a name.' ); |
|
| 49 | } |
||
| 50 | |||
| 51 | 6 | if ( empty( $this->getFilepath() ) ) { |
|
| 52 | 1 | throw new Exception( 'View must have a filepath.' ); |
|
| 53 | } |
||
| 54 | |||
| 55 | 5 | $context = $this->getContext(); |
|
| 56 | 5 | $this->with( ['global' => View::getGlobals()] ); |
|
| 57 | 5 | View::compose( $this ); |
|
| 58 | 5 | $this->with( $context ); |
|
| 59 | |||
| 60 | 5 | $renderer = function() { |
|
| 61 | 5 | ob_start(); |
|
| 62 | 5 | $__context = $this->getContext(); |
|
| 63 | 5 | extract( $__context ); |
|
| 64 | 5 | include( $this->getFilepath() ); |
|
| 65 | 5 | return ob_get_clean(); |
|
| 66 | 5 | }; |
|
| 67 | |||
| 68 | 5 | return $renderer(); |
|
| 69 | } |
||
| 70 | |||
| 80 |