From 421e2a45b11dc817a4709e5c8e852aac345c0bed Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Wed, 27 May 2020 08:36:04 +0200 Subject: [PATCH] allow doctrine/inflector 2 --- .travis.yml | 1 + composer.json | 4 ++-- src/Packagist/Api/Result/AbstractResult.php | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b2ff8e..1778618 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - '7.1' - '7.2' - '7.3' + - '7.4' before_script: - composer install --dev diff --git a/composer.json b/composer.json index 4aa882a..c1c77bc 100644 --- a/composer.json +++ b/composer.json @@ -14,10 +14,10 @@ "require": { "php": ">=7.1", "guzzlehttp/guzzle": "~6.0", - "doctrine/inflector": "~1.0" + "doctrine/inflector": "~1.0 || ~2.0" }, "require-dev": { - "phpspec/phpspec": "~5.1", + "phpspec/phpspec": "~5.1 || ~6.0", "squizlabs/php_codesniffer": "^3.0" }, "config": { diff --git a/src/Packagist/Api/Result/AbstractResult.php b/src/Packagist/Api/Result/AbstractResult.php index c0c59bb..e9182c1 100644 --- a/src/Packagist/Api/Result/AbstractResult.php +++ b/src/Packagist/Api/Result/AbstractResult.php @@ -3,6 +3,7 @@ namespace Packagist\Api\Result; use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; abstract class AbstractResult { @@ -11,8 +12,9 @@ abstract class AbstractResult */ public function fromArray(array $data) { + $inflector = \class_exists(InflectorFactory::class) ? InflectorFactory::create()->build() : null; foreach ($data as $key => $value) { - $property = Inflector::camelize($key); + $property = null === $inflector ? Inflector::camelize($key) : $inflector->camelize($key); $this->$property = $value; } }