| Total Complexity | 12 |
| Total Lines | 129 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class Pattern |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * if methods === null -> full methods |
||
| 10 | * |
||
| 11 | * @var null|array |
||
| 12 | */ |
||
| 13 | protected $methods; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | protected $defaults = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $name; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $path; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Pattern constructor. |
||
| 32 | * @param string $path |
||
| 33 | * @param string $name |
||
| 34 | */ |
||
| 35 | public function __construct(string $path, ?string $name) |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | public function getName(): string |
||
| 45 | { |
||
| 46 | return $this->name ?: $this->generateName(); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param string $name |
||
| 51 | * @return $this |
||
| 52 | */ |
||
| 53 | public function setName(string $name): self |
||
| 54 | { |
||
| 55 | $this->name = $name; |
||
| 56 | return $this; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return array|null |
||
| 61 | */ |
||
| 62 | public function getMethods(): ?array |
||
| 63 | { |
||
| 64 | return $this->methods; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param array|null $methods |
||
| 69 | * @return $this |
||
| 70 | */ |
||
| 71 | public function setMethods(?array $methods): self |
||
| 72 | { |
||
| 73 | $this->methods = $methods; |
||
| 74 | return $this; |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @return array |
||
| 79 | */ |
||
| 80 | public function getDefaults(): array |
||
| 81 | { |
||
| 82 | return $this->defaults; |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @param array $defaults |
||
| 87 | * @return $this |
||
| 88 | */ |
||
| 89 | public function setDefaults(array $defaults): self |
||
| 90 | { |
||
| 91 | $this->defaults = $defaults; |
||
| 92 | return $this; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @return string |
||
| 97 | */ |
||
| 98 | public function getPath(): string |
||
| 99 | { |
||
| 100 | return $this->path; |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @param string $path |
||
| 105 | * @return $this |
||
| 106 | */ |
||
| 107 | public function setPath(string $path): self |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @return array |
||
| 115 | */ |
||
| 116 | public function toArray(): array |
||
| 124 | ] |
||
| 125 | ]; |
||
| 126 | } |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @return string |
||
| 130 | */ |
||
| 131 | protected function generateName(): string |
||
| 134 | } |
||
| 135 | |||
| 136 | } |
||
| 137 |