| Total Complexity | 7 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 95.83% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class License implements LicenseInterface |
||
| 14 | { |
||
| 15 | private Holder $holder; |
||
| 16 | |||
| 17 | private Period $period; |
||
| 18 | |||
| 19 | private Template $template; |
||
| 20 | |||
| 21 | 8 | public function __construct( |
|
| 22 | Template $fileTemplate, |
||
| 23 | Period $period, |
||
| 24 | Holder $holder |
||
| 25 | ) { |
||
| 26 | 8 | $this->template = $fileTemplate; |
|
| 27 | 8 | $this->period = $period; |
|
| 28 | 8 | $this->holder = $holder; |
|
| 29 | 8 | } |
|
| 30 | |||
| 31 | 1 | public function __toString(): string |
|
| 32 | { |
||
| 33 | 1 | $file = tmpfile(); |
|
| 34 | |||
| 35 | 1 | if (false === $file) { |
|
| 36 | throw new Exception('Unable to generate temporary tmp file.'); |
||
| 37 | } |
||
| 38 | |||
| 39 | 1 | $path = stream_get_meta_data($file)['uri']; |
|
| 40 | |||
| 41 | 1 | $this->toFile($path)->save(); |
|
| 42 | |||
| 43 | 1 | return (string) file_get_contents($path); |
|
| 44 | } |
||
| 45 | |||
| 46 | 1 | public function getHolder(): Holder |
|
| 47 | { |
||
| 48 | 1 | return $this->holder; |
|
| 49 | } |
||
| 50 | |||
| 51 | 1 | public function getPeriod(): Period |
|
| 52 | { |
||
| 53 | 1 | return $this->period; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | public function getTemplate(): Template |
|
| 57 | { |
||
| 58 | 1 | return $this->template; |
|
| 59 | } |
||
| 60 | |||
| 61 | 2 | public function toFile(string $filepath): File |
|
| 68 | ); |
||
| 69 | } |
||
| 70 | } |
||
| 71 |