Passed
Push — 0.8.x ( dc0566...6e510b )
by Alexander
06:23 queued 03:10
created

AboutCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 31
c 2
b 0
f 0
dl 0
loc 72
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 5 1
A buildInfo() 0 23 5
A define() 0 6 1
1
<?php
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2023 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
23
namespace Syscodes\Bundles\ApplicationBundle\Console\Commands;
24
25
use Locale;
26
use Syscodes\Components\Console\Command\Command;
27
use Syscodes\Bundles\ApplicationBundle\Console\Application;
28
use Syscodes\Components\Contracts\Console\Input\Input as InputInterface;
29
use Syscodes\Components\Contracts\Console\Output\Output as OutputInterface;
30
31
/**
32
 * A console command to display information about of system.
33
 */
34
class AboutCommand extends Command
35
{
36
    protected static $defaultName = 'about';
37
    protected static $defaultDescription = 'Display information about the current project';
38
39
    /**
40
     * Gets input definition for command.
41
     * 
42
     * @return void
43
     */
44
    protected function define()
45
    {
46
        $this
47
            ->setName(static::$defaultName)
48
            ->setDescription(static::$defaultDescription)
49
            ->setHelp(<<<'EOT'
50
            The <comment>%command-name%</> command displays information about the current Lenevor project.
51
            
52
            The <comment>PHP</> section displays important configuration that could affect your application. The values might
53
            be different between web and CLI.
54
            EOT
55
            );
56
    }
57
58
    /**
59
     * Executes the current command.
60
     * 
61
     * @param  \Syscodes\Components\Contracts\Console\Input\Input  $input
62
     * @param  \Syscodes\Components\Contracts\Console\Output\Output  $output
63
     * 
64
     * @return int|mixed
65
     * 
66
     * @throws \LogicException
67
     */
68
    protected function execute(InputInterface $input, OutputInterface $output) 
69
    {
70
        echo $this->buildInfo($this->getApplication(), $output);
71
72
        return 0;
73
    }
74
75
    /**
76
     * Returns the info of the console with logo.
77
     * 
78
     * @param  \Syscodes\Bundles\ApplicationBundle\Console\Application  $application
79
     * @param  \Syscodes\Components\Contracts\Console\\Output\Output  $output
0 ignored issues
show
Bug introduced by
The type Syscodes\Components\Cont...\Console\\Output\Output was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
80
     *
81
     * @return string
82
     */
83
    public function buildInfo(Application $application, OutputInterface $output): string
84
    {
85
        $logo         = '';
86
        $phpVersion   = \PHP_VERSION;
0 ignored issues
show
Unused Code introduced by
The assignment to $phpVersion is dead and can be removed.
Loading history...
87
        $phpVersion   = \PHP_VERSION;
88
        $architecture = \PHP_INT_SIZE * 16;
89
        $locale       = class_exists(Locale::class, false) && Locale::getDefault() ? Locale::getDefault() : 'n/a';
90
91
        if ($logoTxt = $application->getLogoText()) {
92
            $logo = $output->commandline($logoTxt, $application->getLogoStyle());
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $logo is correct as $output->commandline($lo...cation->getLogoStyle()) targeting Syscodes\Components\Cont...t\Output::commandline() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
93
        }
94
95
        $info = "$logo\n";
96
        $info .= "  {$application->getName()} Version ".$application->getVersion()."\n";
97
        $info .= "  Core\n";
98
        $info .= "  Environment: ". env('APP_ENV')."\n";
99
        $info .= "  Debug: ". (env('APP_DEBUG') ? "True\n" : "False\n");
100
        $info .= "  PHP Info\n";
101
        $info .= "  Version: "."{$phpVersion}\n";
102
        $info .= "  Architecture: "."{$architecture} bits\n";
103
        $info .= "  Intl Locale: "."{$locale}\n";
104
105
        return $info;
106
    }
107
}