vendor and env first commit

This commit is contained in:
2025-03-28 08:52:46 +01:00
parent f8388bc81b
commit 8f26283832
10976 changed files with 1349952 additions and 2 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Label\Font;
final readonly class Font implements FontInterface
{
public function __construct(
private string $path,
private 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
View File
@@ -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
View File
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Label\Font;
final readonly 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;
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Label;
use Endroid\QrCode\Color\Color;
use Endroid\QrCode\Color\ColorInterface;
use Endroid\QrCode\Label\Font\Font;
use Endroid\QrCode\Label\Font\FontInterface;
use Endroid\QrCode\Label\Margin\Margin;
use Endroid\QrCode\Label\Margin\MarginInterface;
final readonly class Label implements LabelInterface
{
public function __construct(
private string $text,
private FontInterface $font = new Font(__DIR__.'/../../assets/open_sans.ttf', 16),
private LabelAlignment $alignment = LabelAlignment::Center,
private MarginInterface $margin = new Margin(0, 10, 10, 10),
private ColorInterface $textColor = new Color(0, 0, 0),
) {
}
public function getText(): string
{
return $this->text;
}
public function getFont(): FontInterface
{
return $this->font;
}
public function getAlignment(): LabelAlignment
{
return $this->alignment;
}
public function getMargin(): MarginInterface
{
return $this->margin;
}
public function getTextColor(): ColorInterface
{
return $this->textColor;
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Label;
enum LabelAlignment: string
{
case Center = 'center';
case Left = 'left';
case Right = 'right';
}
+22
View File
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Label;
use Endroid\QrCode\Color\ColorInterface;
use Endroid\QrCode\Label\Font\FontInterface;
use Endroid\QrCode\Label\Margin\MarginInterface;
interface LabelInterface
{
public function getText(): string;
public function getFont(): FontInterface;
public function getAlignment(): LabelAlignment;
public function getMargin(): MarginInterface;
public function getTextColor(): ColorInterface;
}
+47
View File
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Label\Margin;
final readonly class Margin implements MarginInterface
{
public function __construct(
private int $top,
private int $right,
private int $bottom,
private int $left,
) {
}
public function getTop(): int
{
return $this->top;
}
public function getRight(): int
{
return $this->right;
}
public function getBottom(): int
{
return $this->bottom;
}
public function getLeft(): int
{
return $this->left;
}
/** @return array<string, int> */
public function toArray(): array
{
return [
'top' => $this->top,
'right' => $this->right,
'bottom' => $this->bottom,
'left' => $this->left,
];
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Endroid\QrCode\Label\Margin;
interface MarginInterface
{
public function getTop(): int;
public function getRight(): int;
public function getBottom(): int;
public function getLeft(): int;
/** @return array<string, int> */
public function toArray(): array;
}