Skip to content

Commit 331c3ab

Browse files
committed
Add doctrine and api platform version to command output
1 parent c47567a commit 331c3ab

File tree

10 files changed

+137
-57
lines changed

10 files changed

+137
-57
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"doctrine/doctrine-bundle": "^2.7",
2222
"doctrine/doctrine-migrations-bundle": "^3.2",
2323
"doctrine/orm": "^2.14",
24-
"ixnode/bash-version-manager": "^0.1.5",
24+
"ixnode/bash-version-manager": "^0.1.7",
2525
"ixnode/php-array-to-object": "^0.1.1",
26-
"ixnode/php-checker": "^0.1.3",
27-
"ixnode/php-container": "^0.1.2",
26+
"ixnode/php-checker": "^0.1.9",
27+
"ixnode/php-container": "^0.1.8",
2828
"ixnode/php-exception": "^0.1.19",
2929
"ixnode/php-json-schema-validator": "^0.1.2",
3030
"ixnode/php-naming-conventions": "^0.1.1",

composer.lock

Lines changed: 26 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"$schema": "resource.schema.json",
33
"name": "ixnode/php-api-version-bundle",
4-
"description": "Provides the base API plattform functionality.",
5-
"version": "0.1.0",
6-
"date": "Friday, December 30, 2022 - 09:45:29",
4+
"description": "Provides the base API plattform functionality",
5+
"version": "0.1.9",
6+
"date": "Sunday, June 25, 2023 - 08:47:18",
77
"license": "Copyright (c) 2022 Björn Hempel",
88
"authors": [
99
"Björn Hempel <bjoern@hempel.li>"
1010
],
11-
"php-version": "8.1.12",
12-
"symfony-version": "6.1.6"
11+
"php-version": "8.2.7",
12+
"symfony-version": "6.3.0",
13+
"composer-version": "2.5.1",
14+
"doctrine-version": "2.15.3",
15+
"api-platform-version": "3.1.12"
1316
}

data/json/schema/command/version/resource.schema.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,23 @@
2828
"type": "string"
2929
}
3030
},
31-
"php-version":{
31+
"php-version": {
3232
"type": "string",
3333
"pattern": "^\\d+\\.\\d+\\.\\d+$"
3434
},
35-
"symfony-version":{
35+
"symfony-version": {
36+
"type": "string",
37+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
38+
},
39+
"composer-version": {
40+
"type": "string",
41+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
42+
},
43+
"doctrine-version": {
44+
"type": "string",
45+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
46+
},
47+
"api-platform-version": {
3648
"type": "string",
3749
"pattern": "^\\d+\\.\\d+\\.\\d+$"
3850
}

src/ApiPlatform/State/Base/Raw/BaseRawProvider.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/*
64
* This file is part of the ixnode/php-api-version-bundle project.
75
*
@@ -11,20 +9,23 @@
119
* file that was distributed with this source code.
1210
*/
1311

12+
declare(strict_types=1);
13+
1414
namespace Ixnode\PhpApiVersionBundle\ApiPlatform\State\Base\Raw;
1515

1616
use ApiPlatform\Metadata\Operation;
1717
use Ixnode\PhpApiVersionBundle\ApiPlatform\Resource\Base\BasePublicResource;
1818
use Ixnode\PhpApiVersionBundle\ApiPlatform\State\Base\BaseProvider;
19+
use Ixnode\PhpException\Case\CaseInvalidException;
1920
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
2021

2122
/**
2223
* Class BaseRawProvider
2324
*
2425
* Use this Provider to provide the raw data of the given BasePublicResource (doProvide) without any API specific wrapper information:
2526
*
26-
* - data ressource
27-
* - given ressource
27+
* - data resource
28+
* - given resource
2829
* - valid state of request
2930
* - date of request
3031
* - time-taken for request
@@ -49,6 +50,7 @@ public function __construct(protected ParameterBagInterface $parameterBag)
4950
* @param array<string, mixed> $uriVariables
5051
* @param array<int|string, mixed> $context
5152
* @return BasePublicResource|BasePublicResource[]
53+
* @throws CaseInvalidException
5254
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5355
*/
5456
public function provide(Operation $operation, array $uriVariables = [], array $context = []): BasePublicResource|array
@@ -62,6 +64,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
6264
* @param array<string, mixed> $uriVariables
6365
* @param array<int|string, mixed> $context
6466
* @return BasePublicResource
67+
* @throws CaseInvalidException
6568
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6669
*/
6770
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): BasePublicResource

src/ApiPlatform/State/VersionProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/*
64
* This file is part of the ixnode/php-api-version-bundle project.
75
*
@@ -11,6 +9,8 @@
119
* file that was distributed with this source code.
1210
*/
1311

12+
declare(strict_types=1);
13+
1414
namespace Ixnode\PhpApiVersionBundle\ApiPlatform\State;
1515

1616
use Ixnode\PhpApiVersionBundle\ApiPlatform\Resource\Base\BasePublicResource;

src/Command/Version/VersionCommand.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
namespace Ixnode\PhpApiVersionBundle\Command\Version;
1515

1616
use Exception;
17-
use Ixnode\BashVersionManager\Version;
1817
use Ixnode\PhpApiVersionBundle\Utils\TypeCasting\TypeCastingHelper;
18+
use Ixnode\PhpApiVersionBundle\Utils\Version\Version;
1919
use Ixnode\PhpContainer\Json;
2020
use Ixnode\PhpException\Case\CaseInvalidException;
2121
use Ixnode\PhpException\File\FileNotFoundException;
@@ -29,7 +29,6 @@
2929
use Symfony\Component\Console\Input\InputInterface;
3030
use Symfony\Component\Console\Input\InputOption;
3131
use Symfony\Component\Console\Output\OutputInterface;
32-
use Symfony\Component\HttpKernel\Kernel;
3332

3433
/**
3534
* Class VersionCommand
@@ -73,6 +72,12 @@ class VersionCommand extends Command
7372

7473
protected const KEY_SYMFONY = 'symfony-version';
7574

75+
protected const KEY_COMPOSER = 'composer-version';
76+
77+
protected const KEY_DOCTRINE = 'doctrine-version';
78+
79+
protected const KEY_API_PLATFORM = 'api-platform-version';
80+
7681
protected Version $version;
7782

7883
/**
@@ -112,21 +117,18 @@ protected function configure(): void
112117
*/
113118
protected function getVersionArray(): array
114119
{
115-
$authors = [];
116-
117-
foreach (Version::VALUE_AUTHORS as $author) {
118-
$authors[] = $author;
119-
}
120-
121120
return [
122121
self::KEY_NAME => $this->version->getName(),
123122
self::KEY_DESCRIPTION => $this->version->getDescription(),
124123
self::KEY_VERSION => $this->version->getVersion(),
125124
self::KEY_DATE => $this->version->getDate(),
126-
self::KEY_LICENSE => Version::VALUE_LICENSE,
127-
self::KEY_AUTHORS => $authors,
128-
self::KEY_PHP => phpversion(),
129-
self::KEY_SYMFONY => Kernel::VERSION,
125+
self::KEY_LICENSE => $this->version->getLicense(),
126+
self::KEY_AUTHORS => $this->version->getAuthors(),
127+
self::KEY_PHP => $this->version->getVersionPhp(),
128+
self::KEY_SYMFONY => $this->version->getVersionSymfony(),
129+
self::KEY_COMPOSER => $this->version->getVersionComposer(),
130+
self::KEY_DOCTRINE => $this->version->getVersionComposerPackage('doctrine/orm'),
131+
self::KEY_API_PLATFORM => $this->version->getVersionComposerPackage('api-platform/core'),
130132
];
131133
}
132134

@@ -140,7 +142,7 @@ protected function getVersionArray(): array
140142
*/
141143
protected function printText(OutputInterface $output, array $versionArray): void
142144
{
143-
$templateFormat = '%-18s %s';
145+
$templateFormat = '%-25s %s';
144146

145147
$output->writeln('');
146148
foreach ($versionArray as $key => $value) {

src/Utils/Version/Version.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the ixnode/php-api-version-bundle project.
5+
*
6+
* (c) Björn Hempel <https://www.hempel.li/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE.md
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Ixnode\PhpApiVersionBundle\Utils\Version;
15+
16+
use Ixnode\BashVersionManager\Version as BashVersionManager;
17+
use Symfony\Component\HttpKernel\Kernel;
18+
19+
/**
20+
* Class Version
21+
*
22+
* @author Björn Hempel <bjoern@hempel.li>
23+
* @version 0.1.0 (2023-06-25)
24+
* @since 0.1.0 (2023-06-25) First version.
25+
*/
26+
class Version extends BashVersionManager
27+
{
28+
/**
29+
* Returns the symfony version of this application.
30+
*
31+
* @return string
32+
*/
33+
public function getVersionSymfony(): string
34+
{
35+
return Kernel::VERSION;
36+
}
37+
}

0 commit comments

Comments
 (0)