| Total Complexity | 8 |
| Total Lines | 109 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class PathBuilder |
||
| 10 | { |
||
| 11 | |||
| 12 | use SharedInstance; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var int |
||
| 16 | */ |
||
| 17 | protected $depth = 2; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var int |
||
| 21 | */ |
||
| 22 | protected $length = 2; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $charPad = '0'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var int |
||
| 31 | */ |
||
| 32 | protected $typePad = STR_PAD_RIGHT; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * PathBuilder constructor. |
||
| 36 | * |
||
| 37 | * @param int $length |
||
| 38 | * @param int $depth |
||
| 39 | */ |
||
| 40 | 7 | public function __construct($length = 2, $depth = 2) |
|
| 41 | { |
||
| 42 | 7 | $this->length = $length; |
|
| 43 | 7 | $this->depth = $depth; |
|
| 44 | 7 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $data |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | 7 | protected function string($data) |
|
| 52 | { |
||
| 53 | 7 | return \str_pad( |
|
| 54 | 7 | $data, |
|
| 55 | 7 | $this->depth * $this->length, |
|
| 56 | 7 | $this->charPad, |
|
| 57 | 7 | $this->typePad |
|
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param int $data |
||
| 63 | */ |
||
| 64 | 4 | public function setLength($data) |
|
| 65 | { |
||
| 66 | 4 | $this->length = $data; |
|
| 67 | 4 | } |
|
| 68 | |||
| 69 | /** |
||
| 70 | * @param int $data |
||
| 71 | */ |
||
| 72 | 1 | public function setDepth($data) |
|
| 73 | { |
||
| 74 | 1 | $this->depth = $data; |
|
| 75 | 1 | } |
|
| 76 | |||
| 77 | /** |
||
| 78 | * @param string $data |
||
| 79 | */ |
||
| 80 | 3 | public function setCharPad($data) |
|
| 81 | { |
||
| 82 | 3 | $this->charPad = $data; |
|
| 83 | 3 | } |
|
| 84 | |||
| 85 | /** |
||
| 86 | * @param int $data |
||
| 87 | */ |
||
| 88 | 2 | public function setTypePad($data) |
|
| 89 | { |
||
| 90 | 2 | $this->typePad = $data; |
|
| 91 | 2 | } |
|
| 92 | |||
| 93 | /** |
||
| 94 | * @param string $string |
||
| 95 | * |
||
| 96 | * @return array |
||
| 97 | */ |
||
| 98 | 7 | public function hash($string) |
|
| 103 | )); |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * <type>(/<config>)/<hash>{s1}/<hash>{s2}/<hash> |
||
| 108 | * |
||
| 109 | * @param string $type |
||
| 110 | * @param string $hash |
||
| 111 | * @param string $config |
||
| 112 | * |
||
| 113 | * @return string |
||
| 114 | */ |
||
| 115 | 6 | public function generate($type, $config, $hash) |
|
| 118 | } |
||
| 119 | |||
| 121 |