Skip to content

Commit ff86e41

Browse files
authored
Merge pull request #5 from bornfight/feature/inflector
add doctrine inflector
2 parents 8033a04 + 753f169 commit ff86e41

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Command/ApiDocumentationCommand.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
use Bornfight\JsonApiDocumentation\Documentation\EntityDetailsService;
88
use Bornfight\JsonApiDocumentation\Documentation\JsonApiClassParser;
99
use Bornfight\JsonApiDocumentation\Documentation\RouteFactory;
10+
use Doctrine\Inflector\Inflector;
11+
use Doctrine\Inflector\LanguageInflectorFactory;
1012
use Exception;
1113
use Symfony\Bundle\MakerBundle\Str;
1214
use Symfony\Component\Console\Command\Command;
1315
use Symfony\Component\Console\Input\InputInterface;
1416
use Symfony\Component\Console\Output\OutputInterface;
1517
use Symfony\Component\Console\Style\SymfonyStyle;
1618
use Symfony\Component\Filesystem\Filesystem;
17-
use Symfony\Component\String\Inflector\EnglishInflector;
18-
use Symfony\Component\String\Inflector\InflectorInterface;
1919
use Symfony\Component\Yaml\Exception\ParseException;
2020
use Symfony\Component\Yaml\Yaml;
2121

@@ -35,7 +35,7 @@ class ApiDocumentationCommand extends Command
3535
*/
3636
private $routeFactory;
3737
/**
38-
* @var InflectorInterface
38+
* @var Inflector
3939
*/
4040
private $inflector;
4141
/**
@@ -51,16 +51,13 @@ class ApiDocumentationCommand extends Command
5151
*/
5252
private $customHandlers;
5353

54-
/**
55-
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
56-
*/
57-
public function __construct(iterable $customHandlers, string $projectDir, Filesystem $filesystem, RouteFactory $routeFactory, EntityDetailsService $entityDetailsService, JsonApiClassParser $jsonApiClassParser)
54+
public function __construct(iterable $customHandlers, string $projectDir, Filesystem $filesystem, RouteFactory $routeFactory, EntityDetailsService $entityDetailsService, JsonApiClassParser $jsonApiClassParser, LanguageInflectorFactory $languageInflectorFactory)
5855
{
5956
parent::__construct();
6057
$this->projectDir = $projectDir;
6158
$this->filesystem = $filesystem;
6259
$this->routeFactory = $routeFactory;
63-
$this->inflector = new EnglishInflector();
60+
$this->inflector = $languageInflectorFactory->build();
6461
$this->entityDetails = $entityDetailsService->getEntityDetails();
6562
$this->jsonApiClassParser = $jsonApiClassParser;
6663
$this->customHandlers = $customHandlers;
@@ -103,7 +100,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
103100
continue;
104101
}
105102

106-
$routePath = Str::asRoutePath($this->inflector->pluralize($className)[0]);
103+
$routePath = Str::asRoutePath($this->inflector->pluralize($className));
107104
$routeWithId = $routePath . '/{id}';
108105

109106
$attributes = $this->jsonApiClassParser->getTransformerAttributes($className);

0 commit comments

Comments
 (0)