| Total Complexity | 6 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class FileInput |
||
| 11 | { |
||
| 12 | public string $fileName = ''; |
||
| 13 | public int $filePosition = 0; |
||
| 14 | public string $targetDir = ''; |
||
| 15 | public bool $enabled = false; |
||
| 16 | |||
| 17 | 5 | public function setData(string $targetDir, string $fileName, bool $enabled): self |
|
| 18 | { |
||
| 19 | 5 | $this->parseName($fileName); |
|
| 20 | 5 | $this->targetDir = $targetDir; |
|
| 21 | 5 | $this->enabled = $enabled; |
|
| 22 | 5 | return $this; |
|
| 23 | } |
||
| 24 | |||
| 25 | 5 | protected function parseName(string $name): void |
|
| 26 | { |
||
| 27 | 5 | if (preg_match('#^(\d+)_(.*)$#', $name, $match)) { |
|
| 28 | 1 | $this->filePosition = intval($match[1]); |
|
| 29 | 1 | $this->fileName = $match[2]; |
|
| 30 | } else { |
||
| 31 | 5 | $this->fileName = $name; |
|
| 32 | } |
||
| 33 | 5 | } |
|
| 34 | |||
| 35 | 5 | public function getName(): string |
|
| 36 | { |
||
| 37 | 5 | return $this->filePosition ? sprintf('%03d_%s', intval($this->filePosition), $this->fileName) : $this->fileName ; |
|
| 38 | } |
||
| 39 | |||
| 40 | 5 | public function getFullName(): string |
|
| 43 | } |
||
| 44 | } |
||
| 45 |