| Conditions | 4 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4.0312 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 22 | 4 | public function __construct(string $link, ?string $filename = null) |
|
| 23 | { |
||
| 24 | 4 | if (filter_var($link, FILTER_VALIDATE_URL) === false) { |
|
| 25 | throw new UnsupportedMediaValue($link, 'document', 'Link is not a valid URL'); |
||
| 26 | } |
||
| 27 | |||
| 28 | 4 | $extension = pathinfo($link, PATHINFO_EXTENSION); |
|
| 29 | |||
| 30 | 4 | if (! in_array($extension, static::SUPPORTED_EXTENSIONS)) { |
|
| 31 | 1 | throw new UnsupportedMediaValue($link, 'document', 'Only PDF documents are supported.'); |
|
| 32 | } |
||
| 33 | |||
| 34 | 3 | $this->link = $link; |
|
| 35 | 3 | $this->filename = empty($filename) ? 'document' : $filename; |
|
| 36 | } |
||
| 49 |