BookPage   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 57
ccs 10
cts 16
cp 0.625
rs 10
c 1
b 0
f 0
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setTitle() 0 2 1
A getSlug() 0 2 1
A addCondition() 0 2 1
A getTitle() 0 2 1
A isAllowed() 0 7 3
A setSlug() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\BookComponent;
5
6
/**
7
 * @author Jakub Konečný
8
 * @property-read bool $allowed
9
 */
10 1
class BookPage {
11
  use \Nette\SmartObject;
12
  public string $slug;
13
  public string $title;
14
  /** @var array of [IBookPageCondition, string] */
15
  protected array $conditions = [];
16
  
17
  public function __construct(string $slug, string $title) {
18 1
    $this->slug = $slug;
19 1
    $this->title = $title;
20 1
  }
21
22
  /**
23
   * @deprecated Access the property directly
24
   */
25
  public function getSlug(): string {
26
    return $this->slug;
27
  }
28
29
  /**
30
   * @deprecated Access the property directly
31
   */
32
  protected function setSlug(string $slug): void {
33
    $this->slug = $slug;
34
  }
35
36
  /**
37
   * @deprecated Access the property directly
38
   */
39
  public function getTitle(): string {
40
    return $this->title;
41
  }
42
43
  /**
44
   * @deprecated Access the property directly
45
   */
46
  protected function setTitle(string $title): void {
47
    $this->title = $title;
48
  }
49
  
50
  /**
51
   * @param mixed $parameter
52
   */
53
  public function addCondition(IBookPageCondition $condition, $parameter): void {
54 1
    $this->conditions[] = [$condition, $parameter];
55 1
  }
56
57
  /**
58
   * @deprecated Access the property directly
59
   */
60
  public function isAllowed(): bool {
61 1
    foreach($this->conditions as $condition) {
62 1
      if(!$condition[0]->isAllowed($condition[1])) {
63 1
        return false;
64
      }
65
    }
66 1
    return true;
67
  }
68
}
69
?>