| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Endroid\QrCode\Label\Font; |
| 6 |
|
| 7 |
final class Font implements FontInterface |
| 8 |
{ |
| 9 |
public function __construct( |
| 10 |
private readonly string $path, |
| 11 |
private readonly int $size = 16 |
| 12 |
) { |
| 13 |
$this->assertValidPath($path); |
| 14 |
} |
| 15 |
|
| 16 |
private function assertValidPath(string $path): void |
| 17 |
{ |
| 18 |
if (!file_exists($path)) { |
| 19 |
throw new \Exception(sprintf('Invalid font path "%s"', $path)); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
public function getPath(): string |
| 24 |
{ |
| 25 |
return $this->path; |
| 26 |
} |
| 27 |
|
| 28 |
public function getSize(): int |
| 29 |
{ |
| 30 |
return $this->size; |
| 31 |
} |
| 32 |
} |