| Conditions | 3 |
| Paths | 3 |
| Total Lines | 26 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 68 | 7 | public function toString() { |
|
| 69 | 7 | if ( empty( $this->getName() ) ) { |
|
| 70 | 1 | throw new Exception( 'View must have a name.' ); |
|
| 71 | } |
||
| 72 | |||
| 73 | 6 | if ( empty( $this->getFilepath() ) ) { |
|
| 74 | 1 | throw new Exception( 'View must have a filepath.' ); |
|
| 75 | } |
||
| 76 | |||
| 77 | 5 | $global_context = ['global' => View::getGlobals()]; |
|
| 78 | 5 | $local_context = $this->getContext(); |
|
| 79 | |||
| 80 | 5 | $this->with( $global_context ); |
|
| 81 | 5 | View::compose( $this ); |
|
| 82 | 5 | $this->with( $local_context ); |
|
| 83 | |||
| 84 | 5 | $renderer = function() { |
|
| 85 | 5 | ob_start(); |
|
| 86 | 5 | $__context = $this->getContext(); |
|
| 87 | 5 | extract( $__context ); |
|
| 88 | 5 | include( $this->getFilepath() ); |
|
| 89 | 5 | return ob_get_clean(); |
|
| 90 | 5 | }; |
|
| 91 | |||
| 92 | 5 | return $renderer(); |
|
| 93 | } |
||
| 94 | |||
| 104 |