Skip to content

Commit ba7b647

Browse files
committed
Removed symfony/intl dependency
1 parent d29b05b commit ba7b647

22 files changed

+7
-971
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vendor/
22
bin/
33
tools/
4+
var/
45
.DS_Store
56
.idea

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=7.2",
19-
"symfony/intl": "^3.4|^4.0|^5.0"
18+
"php": ">=7.2"
2019
},
2120
"require-dev": {
2221
"phpunit/phpunit": "^9.5"

src/Coduo/ToString/StringConverter.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,19 @@ class StringConverter
99
*/
1010
private $value;
1111

12-
/**
13-
* @var string
14-
*/
15-
private $locale;
16-
1712
/**
1813
* @param mixed $value
19-
* @param string $locale
2014
*/
21-
public function __construct($value, $locale = 'en')
15+
public function __construct($value)
2216
{
2317
$this->value = $value;
24-
$this->locale = $locale;
2518
}
2619

2720
public function __toString()
2821
{
2922
$type = \gettype($this->value);
3023

3124
switch ($type) {
32-
case 'float':
33-
case 'double':
34-
return $this->castDoubleToString();
3525
case 'boolean':
3626
return $this->castBooleanToString();
3727
case 'object':
@@ -40,7 +30,8 @@ public function __toString()
4030
return \sprintf('Array(%d)', \count($this->value));
4131
case 'resource':
4232
return \sprintf('Resource(%s)', \get_resource_type($this->value));
43-
33+
case 'float':
34+
case 'double':
4435
default:
4536
return (string) $this->value;
4637
}
@@ -63,14 +54,4 @@ private function castBooleanToString()
6354
{
6455
return ($this->value) ? 'true' : 'false';
6556
}
66-
67-
/**
68-
* @return string
69-
*/
70-
private function castDoubleToString()
71-
{
72-
$formatter = new \NumberFormatter($this->locale, \NumberFormatter::DEFAULT_STYLE);
73-
74-
return $formatter->format($this->value);
75-
}
7657
}

tests/Coduo/ToString/Unit/StringConverterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public function test_convert_closure_to_string() : void
6060

6161
public function test_convert_double_to_string_for_specific_locale() : void
6262
{
63-
$converter = new StringConverter(1.1, 'en');
64-
$this->assertSame('1.1', $converter->__toString());
63+
$converter = new StringConverter(1000.10002);
64+
$this->assertSame('1000.10002', $converter->__toString());
6565
}
6666

6767
public function test_convert_resource_to_string() : void

var/.php_cs.cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

var/phpunit/.result.cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)