First Commit
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Endroid\QrCode\Label\Font;
|
||||
|
||||
final class Font implements FontInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $path,
|
||||
private readonly int $size = 16
|
||||
) {
|
||||
$this->assertValidPath($path);
|
||||
}
|
||||
|
||||
private function assertValidPath(string $path): void
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('Invalid font path "%s"', $path));
|
||||
}
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getSize(): int
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Endroid\QrCode\Label\Font;
|
||||
|
||||
interface FontInterface
|
||||
{
|
||||
public function getPath(): string;
|
||||
|
||||
public function getSize(): int;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Endroid\QrCode\Label\Font;
|
||||
|
||||
final class NotoSans implements FontInterface
|
||||
{
|
||||
public function __construct(
|
||||
private int $size = 16
|
||||
) {
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
return __DIR__.'/../../../assets/noto_sans.otf';
|
||||
}
|
||||
|
||||
public function getSize(): int
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Endroid\QrCode\Label\Font;
|
||||
|
||||
final class OpenSans implements FontInterface
|
||||
{
|
||||
public function __construct(
|
||||
private int $size = 16
|
||||
) {
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
return __DIR__.'/../../../assets/open_sans.ttf';
|
||||
}
|
||||
|
||||
public function getSize(): int
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user