Skip to content

Commit

Permalink
Method LastDragon_ru\LaraASP\Formatter\Formatter::time() should retur…
Browse files Browse the repository at this point in the history
…n string but returns string|false.

Method LastDragon_ru\LaraASP\Formatter\Formatter::date() should return string but returns string|false.

Method LastDragon_ru\LaraASP\Formatter\Formatter::datetime() should return string but returns string|false.

Parameter #1 $value of method LastDragon_ru\LaraASP\Formatter\Formatter::decimal() expects float|null, float|int<min, 1023> given.

Parameter #3 $length of function mb_substr expects int|null, float|int given.

Parameter #2 $length of function str_pad expects int, float|int given.

Method LastDragon_ru\LaraASP\Formatter\Formatter::getIntlNumberFormatter() should return NumberFormatter but returns IntlDateFormatter|NumberFormatter.

Parameter #1 $attribute of method NumberFormatter::setAttribute() expects int, int|string given.

Parameter #1 $symbol of method NumberFormatter::setSymbol() expects int, int|string given.

Parameter #1 $attribute of method NumberFormatter::setTextAttribute() expects int, int|string given.

Method LastDragon_ru\LaraASP\Formatter\Formatter::getIntlDateFormatter() should return IntlDateFormatter but returns IntlDateFormatter|NumberFormatter.
  • Loading branch information
LastDragon-ru committed Aug 14, 2021
1 parent 7150212 commit cb8900c
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 203 deletions.
32 changes: 32 additions & 0 deletions packages/formatter/src/Exceptions/FailedToCreateDateFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Formatter\Exceptions;

use IntlDateFormatter;
use LastDragon_ru\LaraASP\Formatter\PackageException;
use Throwable;

use function sprintf;

class FailedToCreateDateFormatter extends PackageException {
public function __construct(
protected string $type,
protected string|int|null $format,
Throwable $previous = null,
) {
parent::__construct(sprintf(
'Failed to create instance of `%s` for type `%s` with format `%s`.',
IntlDateFormatter::class,
$this->getType(),
$this->getFormat() ?? 'null',
), $previous);
}

public function getType(): string {
return $this->type;
}

public function getFormat(): string|int|null {
return $this->format;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Formatter\Exceptions;

use LastDragon_ru\LaraASP\Formatter\PackageException;
use NumberFormatter;
use Throwable;

use function sprintf;

class FailedToCreateNumberFormatter extends PackageException {
public function __construct(
protected string $type,
Throwable $previous = null,
) {
parent::__construct(sprintf(
'Failed to create instance of `%s` for type `%s`.',
NumberFormatter::class,
$this->getType(),
), $previous);
}

public function getType(): string {
return $this->type;
}
}
36 changes: 36 additions & 0 deletions packages/formatter/src/Exceptions/FailedToFormatDate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\Formatter\Exceptions;

use LastDragon_ru\LaraASP\Formatter\PackageException;
use Throwable;

use function sprintf;

class FailedToFormatDate extends PackageException {
public function __construct(
protected string $type,
protected int $errorCode,
protected string $errorMessage,
Throwable $previous = null,
) {
parent::__construct(sprintf(
'Date formatting for type `%s` failed: `%s` (`%s`).',
$this->getType(),
$this->getErrorMessage(),
$this->getErrorCode(),
), $previous);
}

public function getType(): string {
return $this->type;
}

public function getErrorCode(): int {
return $this->errorCode;
}

public function getErrorMessage(): string {
return $this->errorMessage;
}
}

0 comments on commit cb8900c

Please sign in to comment.