-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
parameters: | ||
level: 6 | ||
level: 10 | ||
paths: | ||
- src | ||
exceptions: | ||
check: | ||
missingCheckedExceptionInThrows: true | ||
uncheckedExceptionClasses: | ||
- Error | ||
ignoreErrors: | ||
- | ||
identifier: trait.unused |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
use Carbon\Carbon; | ||
use Carbon\Exceptions\InvalidFormatException; | ||
use Intervention\Zodiac\Exceptions\RuntimeException; | ||
use Intervention\Zodiac\Interfaces\TranslatableInterface; | ||
use Intervention\Zodiac\Interfaces\ZodiacInterface; | ||
use InvalidArgumentException; | ||
|
@@ -26,49 +27,70 @@ abstract class AbstractZodiac implements ZodiacInterface, TranslatableInterface | |
* | ||
* @see ZodiacInterface::start() | ||
* @throws InvalidFormatException | ||
* @throws RuntimeException | ||
*/ | ||
public function start(): Carbon | ||
Check failure on line 32 in src/AbstractZodiac.php
|
||
{ | ||
return Carbon::create( | ||
$date = Carbon::create( | ||
month: $this->startMonth, | ||
day: $this->startDay | ||
); | ||
|
||
if ($date === false) { | ||
Check failure on line 39 in src/AbstractZodiac.php
|
||
throw new RuntimeException('Unable to create end date of zodiac sign.'); | ||
} | ||
|
||
return $date; | ||
Check failure on line 43 in src/AbstractZodiac.php
|
||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see ZodiacInterface::end() | ||
* @throws InvalidFormatException | ||
* @throws RuntimeException | ||
*/ | ||
public function end(): Carbon | ||
Check failure on line 53 in src/AbstractZodiac.php
|
||
{ | ||
return Carbon::create( | ||
$date = Carbon::create( | ||
month: $this->endMonth, | ||
day: $this->endDay, | ||
hour: 23, | ||
minute: 59, | ||
second: 59 | ||
); | ||
|
||
if ($date === false) { | ||
Check failure on line 63 in src/AbstractZodiac.php
|
||
throw new RuntimeException('Unable to create end date of zodiac sign.'); | ||
} | ||
|
||
return $date; | ||
Check failure on line 67 in src/AbstractZodiac.php
|
||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see ZodiacInterface::localized() | ||
* @throws InvalidArgumentException | ||
* @throws RuntimeException | ||
*/ | ||
public function localized(?string $locale = null): ?string | ||
{ | ||
$translator = $this->translator($locale); | ||
$key = "zodiacs.{$this->name}"; | ||
|
||
if ($translator->has($key)) { | ||
return $translator->get($key); | ||
$translated = match ($translator->has($key)) { | ||
true => $translator->get($key), | ||
false => $translator->get("zodiacs::{$key}"), | ||
}; | ||
|
||
if (is_array($translated)) { | ||
throw new RuntimeException( | ||
'Unable to get translated name from array, should be string.' | ||
); | ||
} | ||
|
||
// return packages default message | ||
return $translator->get("zodiacs::{$key}"); | ||
return $translated; | ||
} | ||
|
||
/** | ||
|