diff --git a/src/Avatar.php b/src/Avatar.php index 5b23735..a9f852d 100644 --- a/src/Avatar.php +++ b/src/Avatar.php @@ -138,7 +138,7 @@ public function getBackgroundLightness(): float */ public function setBackgroundLightness(float $backgroundLightness): void { - $this->backgroundLightness = clamp($backgroundLightness, 0, 1); + $this->backgroundLightness = (float)clamp($backgroundLightness, 0, 1); } /** @@ -159,7 +159,7 @@ public function getTextLightness(): float */ public function setTextLightness(float $textLightness): void { - $this->textLightness = clamp($textLightness, 0, 1); + $this->textLightness = (float)clamp($textLightness, 0, 1); } /** diff --git a/src/Identicon.php b/src/Identicon.php index c3702ff..84609d5 100644 --- a/src/Identicon.php +++ b/src/Identicon.php @@ -100,7 +100,7 @@ public function getSVG(): string /** * Generate a symmetric identicon matrix based on the provided hash * - * @return array The generated symmetric matrix + * @return array> The generated symmetric matrix */ public function generateSymmetricMatrix(): array { @@ -125,7 +125,7 @@ public function generateSymmetricMatrix(): array /** * Returns the symmetry matrix. * - * @return array The symmetry matrix. + * @return array, list> The symmetry matrix. */ private function getSymmetryMatrix(): array { @@ -155,7 +155,7 @@ private function convertStrToBool(string $char): bool * Generates a matrix based on the given offset value. * * @param int $offset The offset value for generating the matrix. Defaults to 0. - * @return array The generated matrix. + * @return array, array> The generated matrix. */ private function generateMatrix(int $offset = 0): array { diff --git a/src/InitialsAvatar.php b/src/InitialsAvatar.php index bd98cb0..320b502 100644 --- a/src/InitialsAvatar.php +++ b/src/InitialsAvatar.php @@ -24,7 +24,7 @@ class InitialsAvatar extends Avatar /** * Constructs a new instance of the class. * - * @param Name $name The name object to set + * @param Name $name The name object to set * * @return void */ @@ -46,7 +46,7 @@ public static function make(Name|string $name): InitialsAvatar /** * Sets the form of the application * - * @param string|FormTypes $form The form type + * @param string|FormTypes $form The form type * @return void */ public function setForm(string|FormTypes $form): void @@ -61,7 +61,7 @@ public function setForm(string|FormTypes $form): void /** * Sets the rotation angle of the element * - * @param int $angle The rotation angle value + * @param int $angle The rotation angle value * * @return void */ @@ -83,7 +83,7 @@ public function getOffset(): int /** * Sets the offset for the avatar * - * @param int $offset The offset in pixel + * @param int $offset The offset in pixel * @return void */ public function setOffset(int $offset): void @@ -94,7 +94,7 @@ public function setOffset(int $offset): void /** * Returns the HTML representation of the code. * - * @param bool $base64 Determines if the image source should be in base64 format. Default is false. + * @param bool $base64 Determines if the image source should be in base64 format. Default is false. * @return string The HTML representation of the code. */ public function getHTML(bool $base64 = false): string @@ -103,7 +103,7 @@ public function getHTML(bool $base64 = false): string return $this->generate(); } - return ''; + return ''; } /** @@ -139,9 +139,7 @@ public function generate(): string $initials = $this->getInitials($darkColor); - if (isset($outlineForm)) { - $doc->addChild($outlineForm); - } + $doc->addChild($outlineForm); $doc->addChild($initials); return $larvatar; @@ -154,15 +152,15 @@ public function generate(): string private function addFontIfNotEmpty(): void { if ($this->fontPath != '' && $this->fontFamily != '') { - SVG::addFont(__DIR__.$this->fontPath); + SVG::addFont(__DIR__ . $this->fontPath); } } /** * Get a circle SVG element * - * @param float $halfSize Half of the size of the circle - * @param HSLColor $lightColor The light color to fill the circle with + * @param float $halfSize Half of the size of the circle + * @param HSLColor $lightColor The light color to fill the circle with * @return SVGCircle The circle SVG element */ private function getCircle(float $halfSize, HSLColor $lightColor): SVGCircle @@ -176,8 +174,8 @@ private function getCircle(float $halfSize, HSLColor $lightColor): SVGCircle /** * Get a square SVGRect * - * @param float $size Half of the square size - * @param HSLColor $lightColor The color of the square + * @param float $size Half of the square size + * @param HSLColor $lightColor The color of the square * * @return SVGRect The generated square SVGRect object */ @@ -191,9 +189,9 @@ private function getSquare(float $size, HSLColor $lightColor): SVGRect /** * Get a polygon shape * - * @param float $size The size of the polygon - * @param HSLColor $lightColor The light color to fill the polygon - * @param int $rotation + * @param float $size The size of the polygon + * @param HSLColor $lightColor The light color to fill the polygon + * @param int $rotation * @return SVGPolygon The polygon shape with the specified size and color */ private function getHexagon(float $size, HSLColor $lightColor, int $rotation = 0): SVGPolygon @@ -232,7 +230,7 @@ private function getInitials(HSLColor $darkColor): SVGText if ($this->fontSize == 0) { $this->fontSize = $this->calculateFontSize($initialsText); } - $initials->setFontSize($this->fontSize.'px'); + $initials->setFontSize($this->fontSize . 'px'); return $initials; } @@ -240,7 +238,7 @@ private function getInitials(HSLColor $darkColor): SVGText /** * Calculate the font size based on the initials length * - * @param string $initials The initials to calculate the font size for + * @param string $initials The initials to calculate the font size for * @return int The calculated font size */ protected function calculateFontSize(string $initials): int @@ -255,6 +253,6 @@ protected function calculateFontSize(string $initials): int */ public function getBase64(): string { - return 'data:image/svg+xml;base64,'.base64_encode($this->generate()); + return 'data:image/svg+xml;base64,' . base64_encode($this->generate()); } } diff --git a/src/Name.php b/src/Name.php index a0e48ea..bce36e4 100644 --- a/src/Name.php +++ b/src/Name.php @@ -11,7 +11,7 @@ class Name */ private string $name = ''; /** - * @var array $splitNames An array to store split names + * @var array $splitNames An array to store split names */ private array $splitNames; /** @@ -37,25 +37,25 @@ private function hash(): string } /** - * Get the hexadecimal color value + * Create an instance of the Name class. * - * @param int $offset The starting offset for the substring - * @return HexColor The hexadecimal color string + * @param string $name The name to be used for creating the Name object. + * @return Name The newly created Name object. */ - public function getHexColor(int $offset = 0): HexColor + public static function make(string $name): Name { - return HexColor::create('#'.substr($this->hash, $offset, 6)); + return new Name($name); } /** - * Create an instance of the Name class. + * Get the hexadecimal color value * - * @param string $name The name to be used for creating the Name object. - * @return Name The newly created Name object. + * @param int $offset The starting offset for the substring + * @return HexColor The hexadecimal color string */ - public static function make(string $name): Name + public function getHexColor(int $offset = 0): HexColor { - return new Name($name); + return HexColor::create('#' . substr($this->hash, $offset, 6)); } /** @@ -96,7 +96,7 @@ public function getInitials(): string /** * Retrieves the split names. * - * @return array The split names. + * @return array The split names. */ public function getSplitNames(): array { diff --git a/src/Traits/ColorTrait.php b/src/Traits/ColorTrait.php index 1e6c935..59a500e 100644 --- a/src/Traits/ColorTrait.php +++ b/src/Traits/ColorTrait.php @@ -10,10 +10,10 @@ trait ColorTrait /** * Get the color set for a given name. * - * @param Name $name The name to get the color set for. - * @param float $textLightness The lightness value for the text color. Default is 0.35. - * @param float $backgroundLightness The lightness value for the background color. Default is 0.8. - * @return array An array containing the dark and light colors in HSL format. + * @param Name $name The name to get the color set for. + * @param float $textLightness The lightness value for the text color. Default is 0.35. + * @param float $backgroundLightness The lightness value for the background color. Default is 0.8. + * @return array An array containing the dark and light colors in HSL format. */ public function getColorSet(Name $name, float $textLightness = 0.35, float $backgroundLightness = 0.8): array {