BookControl2   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
c 2
b 0
f 0
dl 0
loc 29
rs 10
wmc 4

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ __construct() 0 22 2
renderSlug1() 0 2 ?
A hp$0 ➔ isAllowed() 0 2 1
A hp$0 ➔ renderSlug1() 0 2 1
__construct() 0 22 ?
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\BookComponent;
5
6
final class BookControl2 extends BookControl {
7
  public function __construct() {
8
    parent::__construct("Test", __DIR__);
9
    $this->pages = function(): BookPagesStorage {
10
      $storage = new BookPagesStorage();
11
      $storage[] = new BookPage("slug1", "title1");
12
      $storage[] = new BookPage("slug2", "title2");
13
      $storage[] = new BookPage("slug3", "title3");
14
      $conditionalPage = new BookPage("slug4", "title4");
15
      $conditionalPage->addCondition(new class() implements IBookPageCondition {
16
        /**
17
         * @param mixed $parameter
18
         */
19
        public function isAllowed($parameter = null): bool {
20
          return false;
21
        }
22
      }, null);
23
      $storage[] = $conditionalPage;
24
      return $storage;
25
    };
26
    $this->onRender[] = function(BookControl $book, string $page): void {
27
      if($page === "slug1") {
28
        $book->template->var2 = "Dota.";
1 ignored issue
show
Bug introduced by
The property var2 does not seem to exist on Nette\Bridges\ApplicationLatte\Template.
Loading history...
29
      }
30
    };
31
  }
32
  
33
  public function renderSlug1(): void {
34
    $this->template->var1 = "Lorem Ipsum.";
1 ignored issue
show
Bug introduced by
The property var1 does not seem to exist on Nette\Bridges\ApplicationLatte\Template.
Loading history...
35
  }
36
}
37
?>