From 99212285a4f58459542b771b9f2787e86c7dd568 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Mon, 14 Oct 2024 15:50:17 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20=E2=AC=86=EF=B8=8F=20bump=20to=20v4.0.?= =?UTF-8?q?4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 + apiConfig.readonly.json | 2 +- composer.json | 3 +- composer.lock | 186 ++++++++++++++++++++-------------------- src/Traits/BaseEnum.php | 24 +++--- 5 files changed, 112 insertions(+), 106 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63d4e3c..24e2962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ### All notable changes to `CRM CLient V4` will be documented in this file. +# version 4.0.4 +- chore: :arrow_up: bump to v4.0.4 + # version 4.0.3 - chore: :arrow_up: bump to v4.0.3 diff --git a/apiConfig.readonly.json b/apiConfig.readonly.json index dcb0a3c..cd71231 100644 --- a/apiConfig.readonly.json +++ b/apiConfig.readonly.json @@ -1,5 +1,5 @@ { - "version": "4.0.3", + "version": "4.0.4", "timestampTimeout": 30, "apiRequestRatePerMinute": 256, "servicesDBCache": 10 diff --git a/composer.json b/composer.json index 85417d4..936d23d 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "library", "description": "LDC CRM Client V4", "license": "MIT", - "version": "4.0.3", + "version": "4.0.4", "authors": [ { "name": "Jérémy Munsch", @@ -20,6 +20,7 @@ ], "require": { "php": "^8.2", + "doctrine/inflector": "^2.0", "ext-curl": "*", "guzzlehttp/guzzle": "^7.4", "respect/validation": "^2.2" diff --git a/composer.lock b/composer.lock index ad4b1a1..5e0b0d7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,99 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "46d0f076c74afaa5b636e0b6283ad48e", + "content-hash": "eb380867bcf551762b352ecb8f201c22", "packages": [ + { + "name": "doctrine/inflector", + "version": "2.0.10", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^11.0", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^8.5 || ^9.5", + "vimeo/psalm": "^4.25 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", + "homepage": "https://www.doctrine-project.org/projects/inflector.html", + "keywords": [ + "inflection", + "inflector", + "lowercase", + "manipulation", + "php", + "plural", + "singular", + "strings", + "uppercase", + "words" + ], + "support": { + "issues": "https://github.com/doctrine/inflector/issues", + "source": "https://github.com/doctrine/inflector/tree/2.0.10" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], + "time": "2024-02-18T20:23:39+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "7.8.0", @@ -1097,97 +1188,6 @@ }, "time": "2022-10-27T11:44:00+00:00" }, - { - "name": "doctrine/inflector", - "version": "2.0.8", - "source": { - "type": "git", - "url": "https://github.com/doctrine/inflector.git", - "reference": "f9301a5b2fb1216b2b08f02ba04dc45423db6bff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/f9301a5b2fb1216b2b08f02ba04dc45423db6bff", - "reference": "f9301a5b2fb1216b2b08f02ba04dc45423db6bff", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^11.0", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.3", - "phpunit/phpunit": "^8.5 || ^9.5", - "vimeo/psalm": "^4.25 || ^5.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", - "homepage": "https://www.doctrine-project.org/projects/inflector.html", - "keywords": [ - "inflection", - "inflector", - "lowercase", - "manipulation", - "php", - "plural", - "singular", - "strings", - "uppercase", - "words" - ], - "support": { - "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.8" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", - "type": "tidelift" - } - ], - "time": "2023-06-16T13:40:37+00:00" - }, { "name": "doctrine/instantiator", "version": "2.0.0", @@ -8972,7 +8972,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.1", + "php": "^8.2", "ext-curl": "*" }, "platform-dev": [], diff --git a/src/Traits/BaseEnum.php b/src/Traits/BaseEnum.php index ae3b85f..c895a72 100644 --- a/src/Traits/BaseEnum.php +++ b/src/Traits/BaseEnum.php @@ -2,7 +2,7 @@ namespace LDC\LDCCRM\Traits; -use Illuminate\Support\Str; +use Doctrine\Inflector\InflectorFactory; trait BaseEnum { @@ -53,8 +53,8 @@ trait BaseEnum if (!\is_null($labels) and !isset($labels[$enum->name])) { throw new \Error('Missing definition label ' . self::class . " for {$enum->name}"); } - $array = array_merge($array, [$enum->name => \trans( - !\is_null($labels) ? $labels[$enum->name] : Str::ucfirst($enum->name) + $array = array_merge($array, [$enum->name => __( + !\is_null($labels) ? $labels[$enum->name] : ucfirst($enum->name) )]); }, self::cases()); self::setCache('labels', $array); @@ -99,14 +99,15 @@ trait BaseEnum if (empty(self::getCache('enums'))) { $definitions = self::getCustomDefinitions(); $array = []; - \array_map(function ($enum) use (&$array, $definitions) { + $inflector = InflectorFactory::create()->build(); + \array_map(function ($enum) use (&$array, $definitions, $inflector) { $baseArray = [ 'name' => $enum->name, 'label' => $enum->label(), 'value' => $enum->value, ]; foreach ($definitions as $index => $elements) { - $index = Str::lower(Str::singular($index)); + $index = $inflector->singularize(strtolower($index)); if (!isset($elements[$enum->name])) { throw new \Error("Missing definition {$index} " . self::class . " for {$enum->name}"); } @@ -115,7 +116,7 @@ trait BaseEnum $array = array_merge($array, [$enum->name => (object)$baseArray]); }, self::cases()); self::setCache('enums', $array); - } + } //end if return self::getCache('enums'); } @@ -250,19 +251,20 @@ trait BaseEnum $names = array_merge($names, [$enum->name => $enum]); }, self::cases()); - $GLOBALS[self::class]['customProps'] = \array_map( - function (mixed $enum) use ($names) { - if (!\is_array($enum)) { + $GLOBALS[self::class]['customProps'] = \array_filter( + (new \ReflectionClass(self::class))->getConstants(), + function (mixed $constant, string $key) use ($names) { + if ($key === 'LABELS' or !\is_array($constant)) { return false; } return count(\array_filter( - $enum, + array_flip($constant), function (string $name) use ($names) { return array_key_exists($name, $names); } )); }, - array_flip((new \ReflectionClass(self::class))->getConstants()), + ARRAY_FILTER_USE_BOTH ); } //end if return $GLOBALS[self::class]['customProps'];