Skip to content

Commit

Permalink
Code: add types
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 12, 2023
1 parent 700d1f2 commit 408621d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/Filters/GravatarFilter.php
Expand Up @@ -13,6 +13,7 @@ public static function filter(string $email, array $parameters = []): string
$format = $parameters['format'] ?? 'jpg';
$style = $parameters['style'] ?? 'retro';
$size = $parameters['size'] ?? '80';

return sprintf('https://www.gravatar.com/avatar/%s.%s?default=%s&size=%s', md5($email), $format, $style, $size);
}

Expand Down
55 changes: 22 additions & 33 deletions src/Formatters/NumberFormatter.php
Expand Up @@ -8,38 +8,28 @@
class NumberFormatter
{

/** @var mixed */
private $rawValue;
private mixed $rawValue;

/** @var string */
private $thousands = ' ';
private string $thousands = ' ';

/** @var int */
private $decimals = 2;
private int $decimals = 2;

/** @var string */
private $point = ',';
private string $point = ',';

/** @var callable|null */
private $callback;

/** @var bool */
private $zeros = false;
private bool $zeros = false;

/** @var bool */
private $strict = true;
private bool $strict = true;

/** @var bool */
private $spaces = true;
private bool $spaces = true;

/** @var string */
private $prefix;
private string $prefix;

/** @var string */
private $suffix;
private string $suffix;

/** @var Html */
private $wrapper;
private Html $wrapper;

public function __construct(string $suffix = '', string $prefix = '')
{
Expand All @@ -52,61 +42,67 @@ public function __construct(string $suffix = '', string $prefix = '')
public function setDecimals(int $number): self
{
$this->decimals = $number;

return $this;
}

public function setPoint(string $separator): self
{
$this->point = $separator;

return $this;
}

public function setThousands(string $separator): self
{
$this->thousands = $separator;

return $this;
}

public function setZeros(bool $show = true): self
{
$this->zeros = $show;

return $this;
}

public function setSuffix(string $suffix): self
{
$this->suffix = $suffix;

return $this;
}

public function setPrefix(string $prefix): self
{
$this->prefix = $prefix;

return $this;
}

public function setStrict(bool $throw = true): self
{
$this->strict = $throw;

return $this;
}

public function setSpaces(bool $display = true): self
{
$this->spaces = $display;

return $this;
}

public function setCallback(callable $callback): self
{
$this->callback = $callback;

return $this;
}

/**
* @return mixed
*/
public function getRawValue()
public function getRawValue(): mixed
{
return $this->rawValue;
}
Expand All @@ -116,11 +112,7 @@ public function prototype(): Html
return $this->wrapper;
}

/**
* @param mixed $value
* @return mixed
*/
public function format($value, ?int $decimals = null)
public function format(mixed $value, ?int $decimals = null): mixed
{
if (is_string($value)) {
$value = trim($value);
Expand Down Expand Up @@ -162,10 +154,7 @@ public function format($value, ?int $decimals = null)
}
}

/**
* @param mixed $value
*/
public function formatHtml($value, ?int $decimals = null): Html
public function formatHtml(mixed $value, ?int $decimals = null): Html
{
$wrapper = clone $this->wrapper;
$wrapper->setHtml($this->format($value, $decimals));
Expand Down
3 changes: 2 additions & 1 deletion src/Macros/VersionMacros.php
Expand Up @@ -12,14 +12,15 @@ class VersionMacros extends MacroSet
{

/** @var mixed[] */
private $config;
private array $config;

/**
* @param mixed[] $config
*/
public function __construct(Compiler $compiler, array $config)
{
parent::__construct($compiler);

$this->config = $config;
}

Expand Down

0 comments on commit 408621d

Please sign in to comment.