Skip to content

Commit dac4b43

Browse files
author
Norbert Orzechowicz
committed
Merge pull request #70 from norzechowicz/cleanup
Cleanup
2 parents b7214ce + c0d04f2 commit dac4b43

41 files changed

Lines changed: 246 additions & 219 deletions

Some content is hidden

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

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ matrix:
1616
- php: 5.6
1717
- php: 7.0
1818
- php: hhvm
19-
allow_failures:
20-
- env: DEPENDENCIES='low'
2119

2220
before_install:
2321
- composer self-update

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
],
1616
"require": {
1717
"php": ">=5.3.0",
18-
"symfony/intl": "~2.3",
19-
"symfony/config": "~2.3",
20-
"symfony/translation": "~2.3",
21-
"symfony/yaml": "~2.3",
18+
"symfony/intl": "^2.3|^3.0",
19+
"symfony/config": "^2.3|^3.0",
20+
"symfony/translation": "^2.3|^3.0",
21+
"symfony/yaml": "^2.3|^3.0",
2222
"thunderer/shortcode": "~0.5"
2323
},
2424
"require-dev": {

spec/Coduo/PHPHumanizer/DateTime/FormatterSpec.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,23 @@ function let(Translator $translator)
3030
)->willReturn('10 minut temu');
3131
}
3232

33-
function it_format_datetime_diff(Difference $diff)
33+
function it_format_datetime_diff()
3434
{
35-
$diff->getUnit()->willReturn(new Minute());
36-
$diff->getQuantity()->willReturn(10);
37-
$diff->isPast()->willReturn(true);
35+
$diff = new Difference(
36+
new \DateTime("2015-01-01 00:10:00"),
37+
new \DateTime("2015-01-01 00:00:00")
38+
);
39+
3840
$this->formatDifference($diff)->shouldReturn('10 minutes ago');
3941
}
4042

41-
function it_format_datetime_diff_for_specific_locale(Difference $diff)
43+
function it_format_datetime_diff_for_specific_locale()
4244
{
43-
$diff->getUnit()->willReturn(new Minute());
44-
$diff->getQuantity()->willReturn(10);
45-
$diff->isPast()->willReturn(true);
45+
$diff = new Difference(
46+
new \DateTime("2015-01-01 00:10:00"),
47+
new \DateTime("2015-01-01 00:00:00")
48+
);
49+
4650
$this->formatDifference($diff, 'pl')->shouldReturn('10 minut temu');
4751
}
4852
}

spec/Coduo/PHPHumanizer/DateTime/PreciseFormatterSpec.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,23 @@ function let(Translator $translator)
6262
)->willReturn('через 10 дней, 5 часов');
6363
}
6464

65-
function it_format_compound_datetime_diff(PreciseDifference $diff, CompoundResult $dayResult,
66-
CompoundResult $hourResult)
65+
function it_format_compound_datetime_diff()
6766
{
68-
$dayResult->getUnit()->willReturn(new Day());
69-
$dayResult->getQuantity()->willReturn(10);
70-
$hourResult->getUnit()->willReturn(new Hour());
71-
$hourResult->getQuantity()->willReturn(5);
67+
$diff = new PreciseDifference(
68+
new \DateTime("2015-01-01 00:00:00"),
69+
new \DateTime("2015-01-11 05:00:00")
70+
);
7271

73-
$diff->getCompoundResults()->willReturn(array($dayResult, $hourResult));
74-
$diff->isPast()->willReturn(false);
7572
$this->formatDifference($diff)->shouldReturn('10 days, 5 hours from now');
7673
}
7774

78-
function it_format_compound_datetime_diff_for_specific_locale(PreciseDifference $diff,
79-
CompoundResult $dayResult, CompoundResult $hourResult)
75+
function it_format_compound_datetime_diff_for_specific_locale()
8076
{
81-
$dayResult->getUnit()->willReturn(new Day());
82-
$dayResult->getQuantity()->willReturn(10);
83-
$hourResult->getUnit()->willReturn(new Hour());
84-
$hourResult->getQuantity()->willReturn(5);
85-
86-
$diff->getCompoundResults()->willReturn(array($dayResult, $hourResult));
87-
$diff->isPast()->willReturn(false);
77+
$diff = new PreciseDifference(
78+
new \DateTime("2015-01-01 00:00:00"),
79+
new \DateTime("2015-01-11 05:00:00")
80+
);
81+
8882
$this->formatDifference($diff, 'ru')->shouldReturn('через 10 дней, 5 часов');
8983
}
9084
}

src/Coduo/PHPHumanizer/Collection/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Component\Translation\TranslatorInterface;
66

7-
class Formatter
7+
final class Formatter
88
{
99
/**
1010
* @var \Symfony\Component\Translation\TranslatorInterface

src/Coduo/PHPHumanizer/Collection/Oxford.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,29 @@
22

33
namespace Coduo\PHPHumanizer\Collection;
44

5-
class Oxford
5+
final class Oxford
66
{
77
/**
88
* @var Formatter
99
*/
1010
private $formatter;
1111

12+
/**
13+
* Oxford constructor.
14+
*
15+
* @param Formatter $formatter
16+
*/
1217
public function __construct(Formatter $formatter)
1318
{
1419
$this->formatter = $formatter;
1520
}
1621

22+
/**
23+
* @param $collection
24+
* @param null $limit
25+
*
26+
* @return string
27+
*/
1728
public function format($collection, $limit = null)
1829
{
1930
return $this->formatter->format($collection, $limit);

src/Coduo/PHPHumanizer/CollectionHumanizer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
use Coduo\PHPHumanizer\Collection\Oxford;
77
use Coduo\PHPHumanizer\Translator\Builder;
88

9-
class CollectionHumanizer
9+
final class CollectionHumanizer
1010
{
11+
/**
12+
* @param $collection
13+
* @param null $limit
14+
* @param string $locale
15+
* @return string
16+
*/
1117
public static function oxford($collection, $limit = null, $locale = 'en')
1218
{
1319
$oxford = new Oxford(

src/Coduo/PHPHumanizer/DateTime/Difference.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Coduo\PHPHumanizer\DateTime\Unit\Week;
1212
use Coduo\PHPHumanizer\DateTime\Unit\Year;
1313

14-
class Difference
14+
final class Difference
1515
{
1616
/**
1717
* @var \DateTime

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Coduo\PHPHumanizer\DateTime\Unit;
66

7-
class CompoundResult
7+
final class CompoundResult
88
{
99
/**
1010
* @var \Coduo\PHPHumanizer\DateTime\Unit

src/Coduo/PHPHumanizer/DateTime/Formatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Component\Translation\TranslatorInterface;
66

7-
class Formatter
7+
final class Formatter
88
{
99
/**
1010
* @var \Symfony\Component\Translation\TranslatorInterface

0 commit comments

Comments
 (0)