| Total Complexity | 8 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare( strict_types=1 ); |
||
| 8 | class Page { |
||
| 9 | /** @var string */ |
||
| 10 | protected $title; |
||
| 11 | /** @var WikiController */ |
||
| 12 | protected $controller; |
||
| 13 | /** @var string */ |
||
| 14 | protected $content; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param string $title |
||
| 18 | * @param WikiController $controller |
||
| 19 | */ |
||
| 20 | public function __construct( string $title, WikiController $controller ) { |
||
| 21 | $this->title = $title; |
||
| 22 | $this->controller = $controller; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | public function getTitle() : string { |
||
| 29 | return $this->title; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Get the content of this page |
||
| 34 | * |
||
| 35 | * @param int|null $section A section number to retrieve the content of that section |
||
| 36 | * @return string |
||
| 37 | */ |
||
| 38 | public function getContent( int $section = null ) : string { |
||
| 39 | if ( $this->content === null ) { |
||
| 40 | $this->content = $this->controller->getPageContent( $this->title, $section ); |
||
| 41 | } |
||
| 42 | return $this->content; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Edit this page and update content |
||
| 47 | * |
||
| 48 | * @param array $params |
||
| 49 | */ |
||
| 50 | public function edit( array $params ) { |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * For easier logging etc. |
||
| 69 | * |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | public function __toString() { |
||
| 76 |