These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * This file is part of phpDocumentor. |
||
4 | * |
||
5 | * For the full copyright and license information, please view the LICENSE |
||
6 | * file that was distributed with this source code. |
||
7 | * |
||
8 | * @author Mike van Riel <[email protected]> |
||
9 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
10 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
11 | * @link http://phpdoc.org |
||
12 | */ |
||
13 | |||
14 | namespace phpDocumentor\Application\Console; |
||
15 | |||
16 | use PackageVersions\Versions; |
||
17 | use Symfony\Bundle\FrameworkBundle\Console\Application as BaseApplication; |
||
18 | use Symfony\Component\HttpKernel\KernelInterface; |
||
19 | |||
20 | final class Application extends BaseApplication |
||
21 | { |
||
22 | const VERSION = '@package_version@'; |
||
23 | |||
24 | public function __construct(KernelInterface $kernel) |
||
25 | { |
||
26 | parent::__construct($kernel); |
||
27 | |||
28 | $this->setName('phpDocumentor'); |
||
29 | $this->setVersion($this->detectVersion()); |
||
30 | $this->setDefaultCommand('project:run'); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Returns the long version of the application. |
||
35 | * |
||
36 | * @return string The long application version |
||
37 | */ |
||
38 | public function getLongVersion(): string |
||
39 | { |
||
40 | return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion()); |
||
41 | } |
||
42 | |||
43 | private function detectVersion(): string |
||
44 | { |
||
45 | $version = static::VERSION; |
||
46 | if (static::VERSION === '@' . 'package_version' . '@') { //prevent replacing the version. |
||
47 | $version = trim(file_get_contents(__DIR__ . '/../../../../VERSION')); |
||
48 | try { |
||
49 | $version = 'v' . \Jean85\PrettyVersions::getVersion(Versions::ROOT_PACKAGE_NAME)->getPrettyVersion(); |
||
50 | } catch (\OutOfBoundsException $e) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
Loading history...
|
|||
51 | } |
||
52 | } |
||
53 | return $version; |
||
54 | } |
||
55 | } |
||
56 |