diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..e3e0ecb --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,41 @@ +name: PHP Composer + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.2' + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run linter + run: vendor/bin/php-cs-fixer fix --dry-run -v + + - name: Run test suite + run: vendor/bin/phpunit --verbose diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6516bbc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php - -php: - - 7.1 - - 7.2 - -cache: - directories: - - vendor - -install: - - travis_retry composer install --no-interaction --prefer-source - -script: - - vendor/bin/php-cs-fixer fix --dry-run -v - - vendor/bin/phpunit --verbose - -matrix: - fast_finish: true diff --git a/composer.json b/composer.json index cd698f1..fc1b195 100644 --- a/composer.json +++ b/composer.json @@ -5,9 +5,9 @@ "type": "library", "license": "BSD-3-Clause", "require": { - "php": ">=7.1", - "doctrine/inflector": "^1.0", - "ramsey/uuid": "^3.8" + "php": ">=7.2", + "ramsey/uuid": "^3.8", + "doctrine/inflector": "^2.0" }, "require-dev": { "phpunit/phpunit": ">=6.0", diff --git a/src/Instantiator/PropertyInstantiator.php b/src/Instantiator/PropertyInstantiator.php index d9a1fdc..df5811a 100644 --- a/src/Instantiator/PropertyInstantiator.php +++ b/src/Instantiator/PropertyInstantiator.php @@ -4,7 +4,7 @@ namespace Linio\Component\Input\Instantiator; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; class PropertyInstantiator implements InstantiatorInterface { @@ -14,10 +14,11 @@ public function instantiate(string $class, ?array $data) return null; } + $inflector = InflectorFactory::create()->build(); $object = new $class(); foreach ($data as $key => $value) { - $property = Inflector::camelize($key); + $property = $inflector->camelize($key); $object->$property = $value; } diff --git a/src/Instantiator/ReflectionInstantiator.php b/src/Instantiator/ReflectionInstantiator.php index c73afd8..7b49d6d 100644 --- a/src/Instantiator/ReflectionInstantiator.php +++ b/src/Instantiator/ReflectionInstantiator.php @@ -4,17 +4,18 @@ namespace Linio\Component\Input\Instantiator; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; class ReflectionInstantiator implements InstantiatorInterface { public function instantiate(string $class, array $data) { + $inflector = InflectorFactory::create()->build(); $object = new $class(); $reflection = new \ReflectionClass($object); foreach ($data as $key => $value) { - $property = $reflection->getProperty(Inflector::camelize($key)); + $property = $reflection->getProperty($inflector->camelize($key)); if (!$property->isPublic()) { $property->setAccessible(true); } diff --git a/src/Instantiator/SetInstantiator.php b/src/Instantiator/SetInstantiator.php index 5b61436..86fd4e9 100644 --- a/src/Instantiator/SetInstantiator.php +++ b/src/Instantiator/SetInstantiator.php @@ -4,16 +4,17 @@ namespace Linio\Component\Input\Instantiator; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; class SetInstantiator implements InstantiatorInterface { public function instantiate(string $class, array $data) { + $inflector = InflectorFactory::create()->build(); $object = new $class(); foreach ($data as $key => $value) { - $method = 'set' . Inflector::classify($key); + $method = 'set' . $inflector->classify($key); $object->$method($value); }