Skip to content

Commit 0533da6

Browse files
committed
Added more strict php cs fixer rules
1 parent b4b5120 commit 0533da6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+238
-242
lines changed

.php_cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Coduo/PHPHumanizer/Aeon/Calendar/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function timeUnit(Unit $unit, string $locale = 'en') : string
3030

3131
foreach ((new UnitCompound($unit))->components() as $component) {
3232
$parts[] = $this->translator->trans(
33-
'compound.'.$component->getUnit()->getName(),
33+
'compound.' . $component->getUnit()->getName(),
3434
['%count%' => $component->getQuantity()],
3535
'difference',
3636
$locale

src/Coduo/PHPHumanizer/Collection/Formatter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(TranslatorInterface $translator, string $catalogue =
2828
/**
2929
* @param array<string> $collection
3030
*/
31-
public function format(array $collection, int $limit = null): string
31+
public function format(array $collection, int $limit = null) : string
3232
{
3333
$count = \count($collection);
3434

@@ -54,7 +54,7 @@ public function format(array $collection, int $limit = null): string
5454
/**
5555
* @param array<string> $collection
5656
*/
57-
private function formatCommaSeparatedWithLimit(array $collection, ?int $limit, int $count): string
57+
private function formatCommaSeparatedWithLimit(array $collection, ?int $limit, int $count) : string
5858
{
5959
$display = \array_map(fn ($element) => (string) $element, \array_slice($collection, 0, $limit));
6060

@@ -69,7 +69,7 @@ private function formatCommaSeparatedWithLimit(array $collection, ?int $limit, i
6969
/**
7070
* @param array<string> $collection
7171
*/
72-
private function formatCommaSeparated(array $collection, int $count): string
72+
private function formatCommaSeparated(array $collection, int $count) : string
7373
{
7474
$display = \array_map(fn ($element) => (string) $element, \array_slice($collection, 0, $count - 1));
7575

@@ -82,7 +82,7 @@ private function formatCommaSeparated(array $collection, int $count): string
8282
/**
8383
* @param array<string> $collection
8484
*/
85-
private function formatOnlyTwo(array $collection): string
85+
private function formatOnlyTwo(array $collection) : string
8686
{
8787
return $this->translator->trans('only_two', [
8888
'%first%' => (string) $collection[0],

src/Coduo/PHPHumanizer/Collection/Oxford.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(Formatter $formatter)
2323
/**
2424
* @param array<string> $collection
2525
*/
26-
public function format(array $collection, int $limit = null): string
26+
public function format(array $collection, int $limit = null) : string
2727
{
2828
return $this->formatter->format($collection, $limit);
2929
}

src/Coduo/PHPHumanizer/CollectionHumanizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class CollectionHumanizer
2020
/**
2121
* @param array<string> $collection
2222
*/
23-
public static function oxford(array $collection, int $limit = null, string $locale = 'en'): string
23+
public static function oxford(array $collection, int $limit = null, string $locale = 'en') : string
2424
{
2525
$oxford = new Oxford(
2626
new Formatter(Builder::build($locale))

src/Coduo/PHPHumanizer/DateTime/DateIntervalCompound.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function components() : array
4343
new Second(),
4444
];
4545

46-
4746
/** @var array<CompoundResult> $compoundResults */
4847
$compoundResults = [];
4948

src/Coduo/PHPHumanizer/DateTime/Difference.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,24 @@ public function __construct(\DateTimeInterface $fromDate, \DateTimeInterface $to
4040
$this->calculate();
4141
}
4242

43-
public function getUnit(): Unit
43+
public function getUnit() : Unit
4444
{
4545
return $this->unit;
4646
}
4747

48-
public function getQuantity(): ?int
48+
public function getQuantity() : ?int
4949
{
5050
return $this->quantity;
5151
}
5252

53-
private function calculate(): void
53+
public function isPast() : bool
54+
{
55+
$diff = $this->toDate->getTimestamp() - $this->fromDate->getTimestamp();
56+
57+
return ($diff > 0) ? false : true;
58+
}
59+
60+
private function calculate() : void
5461
{
5562
/* @var $units Unit[] */
5663
$units = [
@@ -65,9 +72,11 @@ private function calculate(): void
6572
];
6673

6774
$absoluteMilliSecondsDiff = \abs($this->toDate->getTimestamp() - $this->fromDate->getTimestamp()) * 1000;
75+
6876
foreach ($units as $unit) {
6977
if ($absoluteMilliSecondsDiff >= $unit->getMilliseconds()) {
7078
$this->unit = $unit;
79+
7180
break;
7281
}
7382
}
@@ -76,11 +85,4 @@ private function calculate(): void
7685
? $absoluteMilliSecondsDiff
7786
: (int) \round($absoluteMilliSecondsDiff / $this->unit->getMilliseconds());
7887
}
79-
80-
public function isPast(): bool
81-
{
82-
$diff = $this->toDate->getTimestamp() - $this->fromDate->getTimestamp();
83-
84-
return ($diff > 0) ? false : true;
85-
}
8688
}

src/Coduo/PHPHumanizer/DateTime/Difference/CompoundResult.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ final class CompoundResult
1818
private Unit $unit;
1919

2020
/**
21-
* @var int|float
21+
* @var float|int
2222
*/
2323
private $quantity;
2424

2525
/**
26-
* @param int|float $quantity
26+
* @param float|int $quantity
2727
*/
2828
public function __construct(Unit $unit, $quantity)
2929
{
@@ -32,14 +32,14 @@ public function __construct(Unit $unit, $quantity)
3232
}
3333

3434
/**
35-
* @return int|float
35+
* @return float|int
3636
*/
3737
public function getQuantity()
3838
{
3939
return $this->quantity;
4040
}
4141

42-
public function getUnit(): Unit
42+
public function getUnit() : Unit
4343
{
4444
return $this->unit;
4545
}

src/Coduo/PHPHumanizer/DateTime/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(TranslatorInterface $translator)
2222
$this->translator = $translator;
2323
}
2424

25-
public function formatDifference(Difference $difference, string $locale = 'en'): string
25+
public function formatDifference(Difference $difference, string $locale = 'en') : string
2626
{
2727
$translationKey = \sprintf('%s.%s', $difference->getUnit()->getName(), $difference->isPast() ? 'past' : 'future');
2828

src/Coduo/PHPHumanizer/DateTime/PreciseDifference.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class PreciseDifference
1919

2020
private \DateTimeInterface $toDate;
2121

22-
private ?DateIntervalCompound $compoundResults ;
22+
private ?DateIntervalCompound $compoundResults;
2323

2424
public function __construct(\DateTimeInterface $fromDate, \DateTimeInterface $toDate)
2525
{
@@ -40,7 +40,7 @@ public function components() : array
4040
return $this->compoundResults->components();
4141
}
4242

43-
public function isPast(): bool
43+
public function isPast() : bool
4444
{
4545
$diff = $this->toDate->getTimestamp() - $this->fromDate->getTimestamp();
4646

0 commit comments

Comments
 (0)