Skip to content

Commit 415e39a

Browse files
Merge pull request #62 from garak/allow-inflector2
allow doctrine/inflector 2
2 parents 74e1288 + 421e2a4 commit 415e39a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ php:
66
- '7.1'
77
- '7.2'
88
- '7.3'
9+
- '7.4'
910

1011
before_script:
1112
- composer install --dev

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"require": {
1515
"php": ">=7.1",
1616
"guzzlehttp/guzzle": "~6.0",
17-
"doctrine/inflector": "~1.0"
17+
"doctrine/inflector": "~1.0 || ~2.0"
1818
},
1919
"require-dev": {
20-
"phpspec/phpspec": "~5.1",
20+
"phpspec/phpspec": "~5.1 || ~6.0",
2121
"squizlabs/php_codesniffer": "^3.0"
2222
},
2323
"config": {

src/Packagist/Api/Result/AbstractResult.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Packagist\Api\Result;
44

55
use Doctrine\Common\Inflector\Inflector;
6+
use Doctrine\Inflector\InflectorFactory;
67

78
abstract class AbstractResult
89
{
@@ -11,8 +12,9 @@ abstract class AbstractResult
1112
*/
1213
public function fromArray(array $data)
1314
{
15+
$inflector = \class_exists(InflectorFactory::class) ? InflectorFactory::create()->build() : null;
1416
foreach ($data as $key => $value) {
15-
$property = Inflector::camelize($key);
17+
$property = null === $inflector ? Inflector::camelize($key) : $inflector->camelize($key);
1618
$this->$property = $value;
1719
}
1820
}

0 commit comments

Comments
 (0)