Skip to content

Commit 418d663

Browse files
committed
init
1 parent ac5e8c6 commit 418d663

3 files changed

Lines changed: 32 additions & 39 deletions

File tree

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
}
1212
],
1313
"require": {
14-
"php": "8.0",
15-
"doctrine/inflector": "^1.2|^2.0",
16-
"doctrine/cache": "^1.0",
14+
"php": ">=8.2",
15+
"doctrine/inflector": "^2.0",
16+
"doctrine/cache": "^2.2",
1717
"guzzlehttp/guzzle": "^7.0",
1818
"slince/di": "^3.0",
1919
"symfony/yaml": "^4.2|^5.0|^6.0",
20-
"jms/serializer": "^3.10"
20+
"jms/serializer": "^3.28"
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "^7.5|^8.0|^9.0",

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function __construct($shop, CredentialInterface $credential, array $optio
219219

220220
public function __call($name, $arguments)
221221
{
222-
if ('Manager' === substr($name, -7)) {
222+
if (str_ends_with($name, 'Manager')) {
223223
$serviceId = substr($name, 3, -7);
224224
$serviceId = Inflector::tableize(Inflector::pluralize($serviceId));
225225
return $this->container->get($serviceId);

src/Inflector.php

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,42 @@
1313

1414
namespace Slince\Shopify;
1515

16-
use Doctrine\Common\Inflector\Inflector as LegacyInflector;
1716
use Doctrine\Inflector\InflectorFactory;
17+
use Doctrine\Inflector\Inflector as DoctrineInflector;
1818

19-
if (class_exists(InflectorFactory::class)) {
20-
final class Inflector
19+
final class Inflector
20+
{
21+
/**
22+
* @var DoctrineInflector|null
23+
*/
24+
protected static ?DoctrineInflector $inflector = null;
25+
26+
protected static function getInflector(): DoctrineInflector
2127
{
22-
/**
23-
* @var \Doctrine\Inflector\Inflector
24-
*/
25-
protected static $inflector;
26-
27-
protected static function getInflector(): \Doctrine\Inflector\Inflector
28-
{
29-
if (null !== Inflector::$inflector) {
30-
return Inflector::$inflector;
31-
}
32-
return Inflector::$inflector = InflectorFactory::create()->build();
28+
if (null !== Inflector::$inflector) {
29+
return Inflector::$inflector;
3330
}
31+
return Inflector::$inflector = InflectorFactory::create()->build();
32+
}
3433

35-
public static function pluralize(string $word): string
36-
{
37-
return static::getInflector()->pluralize($word);
38-
}
34+
public static function pluralize(string $word): string
35+
{
36+
return Inflector::getInflector()->pluralize($word);
37+
}
3938

40-
public static function tableize(string $word): string
41-
{
42-
return static::getInflector()->tableize($word);
43-
}
39+
public static function tableize(string $word): string
40+
{
41+
return Inflector::getInflector()->tableize($word);
42+
}
4443

45-
public static function classify(string $word): string
46-
{
47-
return static::getInflector()->classify($word);
48-
}
44+
public static function classify(string $word): string
45+
{
46+
return Inflector::getInflector()->classify($word);
47+
}
4948

5049

51-
public static function singularize(string $word)
52-
{
53-
return static::getInflector()->singularize($word);
54-
}
55-
}
56-
} else {
57-
final class Inflector extends LegacyInflector
50+
public static function singularize(string $word)
5851
{
59-
52+
return Inflector::getInflector()->singularize($word);
6053
}
6154
}

0 commit comments

Comments
 (0)