Skip to content

Commit fa52e62

Browse files
committed
Fixxed issue with symfony translator dependency, upgraded php, phpunit and phpspec dependencies
1 parent f989a91 commit fa52e62

File tree

16 files changed

+56
-64
lines changed

16 files changed

+56
-64
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ vendor/
22
bin/
33
composer.lock
44
composer.phar
5-
.php_cs.cache
5+
*.cache

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ matrix:
1010
- php: 7.1
1111
- php: 7.2
1212
- php: 7.3
13+
- php: 7.4
1314

1415
before_install:
1516
- composer self-update

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# PHP Humanizer
22

3-
[![Build Status](https://travis-ci.com/coduo/php-humanizer.svg?branch=master)](https://travis-ci.com/coduo/php-humanizer)
3+
[![Build Status](https://travis-ci.com/coduo/php-humanizer.svg?branch=4.x)](https://travis-ci.com/coduo/php-humanizer)
44
[![Latest Stable Version](https://poser.pugx.org/coduo/php-humanizer/v/stable)](https://packagist.org/packages/coduo/php-humanizer)
55
[![Total Downloads](https://poser.pugx.org/coduo/php-humanizer/downloads)](https://packagist.org/packages/coduo/php-humanizer)
66
[![Latest Unstable Version](https://poser.pugx.org/coduo/php-humanizer/v/unstable)](https://packagist.org/packages/coduo/php-humanizer)
77
[![License](https://poser.pugx.org/coduo/php-humanizer/license)](https://packagist.org/packages/coduo/php-humanizer)
88

99
### Tests
10-
* [![Build Status](https://travis-ci.com/coduo/php-humanizer.svg?branch=master)](https://travis-ci.com/coduo/php-humanizer) - master (3.1)
10+
* [![Build Status](https://travis-ci.com/coduo/php-humanizer.svg?branch=4.x)](https://travis-ci.com/coduo/php-humanizer) - 4.x
1111
* [![Build Status](https://travis-ci.com/coduo/php-humanizer.svg?branch=3.0)](https://travis-ci.com/coduo/php-humanizer) - 3.0
1212

13-
[Readme for master (3.1) version](https://github.com/coduo/php-humanizer/tree/master/README.md)
13+
[Readme for 4.x version](https://github.com/coduo/php-humanizer/tree/4.x/README.md)
1414
[Readme for 3.0 version](https://github.com/coduo/php-humanizer/tree/3.0/README.md)
1515

1616

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=7.0.0",
19-
"symfony/config": "^2.3|^3.0|^4|^5",
20-
"symfony/translation": "^2.3|^3.0|^4|^5",
21-
"symfony/yaml": "^2.3|^3.0|^4|^5"
18+
"php": ">=7.3",
19+
"symfony/config": "^4.4|^5.0",
20+
"symfony/translation": "^4.4|^5.0",
21+
"symfony/yaml": "^4.4|^5.0"
2222
},
2323
"require-dev": {
2424
"thunderer/shortcode": "^0.7",
25-
"phpspec/phpspec": "^2",
26-
"phpunit/phpunit": "^4.5|^5.0",
27-
"friendsofphp/php-cs-fixer": "^2.14"
25+
"phpspec/phpspec": "^6.0",
26+
"phpunit/phpunit": "^8.4",
27+
"friendsofphp/php-cs-fixer": "^2.16"
2828
},
2929
"config": {
3030
"bin-dir": "bin"
@@ -36,12 +36,12 @@
3636
},
3737
"autoload-dev": {
3838
"psr-4": {
39-
"Coduo\\PHPHumanizer\\Tests\\": "tests/"
39+
"": "tests/"
4040
}
4141
},
4242
"extra": {
4343
"branch-alias": {
44-
"dev-master": "3.1-dev"
44+
"dev-master": "4.0-dev"
4545
}
4646
},
4747
"suggest": {

spec/Coduo/PHPHumanizer/Collection/FormatterSpec.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ function let(Translator $translator)
1717
'oxford'
1818
)->willReturn('Michal and Norbert');
1919

20-
$translator->transChoice(
20+
$translator->trans(
2121
'comma_separated_with_limit',
22-
1,
2322
array('%count%' => 1, "%list%" => 'Michal, Norbert'),
2423
'oxford'
2524
)->willReturn('Michal, Norbert and 1 more');

spec/Coduo/PHPHumanizer/Collection/OxfordSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Coduo\PHPHumanizer\Collection\Formatter;
66
use PhpSpec\ObjectBehavior;
77
use Prophecy\Argument;
8-
use Symfony\Component\Translation\TranslatorInterface;
8+
use Symfony\Contracts\Translation\TranslatorInterface;
99

1010
class OxfordSpec extends ObjectBehavior
1111
{

spec/Coduo/PHPHumanizer/DateTime/FormatterSpec.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ class FormatterSpec extends ObjectBehavior
1313
function let(Translator $translator)
1414
{
1515
$this->beConstructedWith($translator);
16-
$translator->transChoice(
16+
$translator->trans(
1717
'minute.past',
18-
10,
1918
array('%count%' => 10),
2019
'difference',
2120
'en'
2221
)->willReturn('10 minutes ago');
2322

24-
$translator->transChoice(
23+
$translator->trans(
2524
'minute.past',
26-
10,
2725
array('%count%' => 10),
2826
'difference',
2927
'pl'
@@ -36,7 +34,7 @@ function it_format_datetime_diff()
3634
new \DateTime("2015-01-01 00:10:00"),
3735
new \DateTime("2015-01-01 00:00:00")
3836
);
39-
37+
4038
$this->formatDifference($diff)->shouldReturn('10 minutes ago');
4139
}
4240

@@ -46,7 +44,7 @@ function it_format_datetime_diff_for_specific_locale()
4644
new \DateTime("2015-01-01 00:10:00"),
4745
new \DateTime("2015-01-01 00:00:00")
4846
);
49-
47+
5048
$this->formatDifference($diff, 'pl')->shouldReturn('10 minut temu');
5149
}
5250
}

spec/Coduo/PHPHumanizer/DateTime/PreciseFormatterSpec.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ class PreciseFormatterSpec extends ObjectBehavior
1515
function let(Translator $translator)
1616
{
1717
$this->beConstructedWith($translator);
18-
$translator->transChoice(
18+
$translator->trans(
1919
'compound.day',
20-
10,
2120
array('%count%' => 10),
2221
'difference',
2322
'en'
2423
)->willReturn('10 days');
2524

26-
$translator->transChoice(
25+
$translator->trans(
2726
'compound.hour',
28-
5,
2927
array('%count%' => 5),
3028
'difference',
3129
'en'
@@ -38,17 +36,15 @@ function let(Translator $translator)
3836
'en'
3937
)->willReturn('10 days, 5 hours from now');
4038

41-
$translator->transChoice(
39+
$translator->trans(
4240
'compound.day',
43-
10,
4441
array('%count%' => 10),
4542
'difference',
4643
'ru'
4744
)->willReturn('10 дней');
4845

49-
$translator->transChoice(
46+
$translator->trans(
5047
'compound.hour',
51-
5,
5248
array('%count%' => 5),
5349
'difference',
5450
'ru'
@@ -66,7 +62,7 @@ function it_format_compound_datetime_diff()
6662
{
6763
$diff = new PreciseDifference(
6864
new \DateTime("2015-01-01 00:00:00"),
69-
new \DateTime("2015-01-11 05:00:00")
65+
new \DateTime("2015-01-11 05:00:00")
7066
);
7167

7268
$this->formatDifference($diff)->shouldReturn('10 days, 5 hours from now');
@@ -78,7 +74,7 @@ function it_format_compound_datetime_diff_for_specific_locale()
7874
new \DateTime("2015-01-01 00:00:00"),
7975
new \DateTime("2015-01-11 05:00:00")
8076
);
81-
77+
8278
$this->formatDifference($diff, 'ru')->shouldReturn('через 10 дней, 5 часов');
8379
}
8480
}

src/Coduo/PHPHumanizer/Collection/Formatter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Coduo\PHPHumanizer\Collection;
1313

14-
use Symfony\Component\Translation\TranslatorInterface;
14+
use Symfony\Contracts\Translation\TranslatorInterface;
1515

1616
final class Formatter
1717
{
1818
/**
19-
* @var \Symfony\Component\Translation\TranslatorInterface
19+
* @var TranslatorInterface
2020
*/
2121
private $translator;
2222

@@ -72,7 +72,7 @@ private function formatCommaSeparatedWithLimit($collection, $limit, $count)
7272

7373
$moreCount = $count - \count($display);
7474

75-
return $this->translator->transChoice('comma_separated_with_limit', $moreCount, [
75+
return $this->translator->trans('comma_separated_with_limit', [
7676
'%list%' => \implode(', ', $display),
7777
'%count%' => $moreCount,
7878
], $this->catalogue);

src/Coduo/PHPHumanizer/DateTime/Formatter.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Coduo\PHPHumanizer\DateTime;
1313

14-
use Symfony\Component\Translation\TranslatorInterface;
14+
use Symfony\Contracts\Translation\TranslatorInterface;
1515

1616
final class Formatter
1717
{
1818
/**
19-
* @var \Symfony\Component\Translation\TranslatorInterface
19+
* @var TranslatorInterface
2020
*/
2121
private $translator;
2222

@@ -38,9 +38,8 @@ public function formatDifference(Difference $difference, $locale = 'en')
3838
{
3939
$translationKey = \sprintf('%s.%s', $difference->getUnit()->getName(), $difference->isPast() ? 'past' : 'future');
4040

41-
return $this->translator->transChoice(
41+
return $this->translator->trans(
4242
$translationKey,
43-
$difference->getQuantity(),
4443
['%count%' => $difference->getQuantity()],
4544
'difference',
4645
$locale

0 commit comments

Comments
 (0)