Issues (108)

src/Application/Application.php (12 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * @copyright Bluz PHP Team
5
 * @link https://github.com/bluzphp/bluzman
6
 */
7
8
namespace Bluzman\Application;
9
10
use Bluz\Config\Config;
0 ignored issues
show
The type Bluz\Config\Config 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...
11
use Bluz\Config\ConfigException;
0 ignored issues
show
The type Bluz\Config\ConfigException 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...
12
use Bluz\Config\ConfigLoader;
0 ignored issues
show
The type Bluz\Config\ConfigLoader 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...
13
use Bluz\Proxy;
0 ignored issues
show
The type Bluz\Proxy 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...
14
use Bluzman\Command;
15
use Symfony\Component\Console;
0 ignored issues
show
The type Symfony\Component\Console 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...
16
use Symfony\Component\Console\Input\InputDefinition;
0 ignored issues
show
The type Symfony\Component\Console\Input\InputDefinition 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...
17
use Symfony\Component\Console\Input\InputOption;
0 ignored issues
show
The type Symfony\Component\Console\Input\InputOption 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...
18
use Symfony\Component\Console\Input\InputArgument;
0 ignored issues
show
The type Symfony\Component\Console\Input\InputArgument 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...
19
20
/**
21
 * @package Bluzman\Application
22
 *
23
 * @author Pavel Machekhin
24
 * @created 2013-11-28 12:31
25
 */
26
class Application extends Console\Application
0 ignored issues
show
The type Symfony\Component\Console\Application 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...
27
{
28
    /**
29
     * @param string $name
30 15
     * @param string $version
31
     */
32 15
    public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
33
    {
34 15
        parent::__construct($name, $version);
35 15
36
        $this->registerCommands();
37
    }
38
39
    /**
40
     * init
41
     *
42
     * @return void
43
     * @throws ConfigException
44
     */
45
    public function init()
46
    {
47
        $loader = new ConfigLoader();
48
        $loader->setPath(PATH_APPLICATION);
0 ignored issues
show
The constant Bluzman\Application\PATH_APPLICATION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
49
        $loader->setEnvironment(BLUZ_ENV);
0 ignored issues
show
The constant Bluzman\Application\BLUZ_ENV was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
50
        $loader->load();
51
52
        $config = new Config();
53
        $config->setFromArray($loader->getConfig());
54
55
        Proxy\Config::setInstance($config);
0 ignored issues
show
The type Bluz\Proxy\Config 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...
56
    }
57
58
    /**
59
     * Removed some commands from default input definition.
60
     *
61 11
     * @return InputDefinition An InputDefinition instance
62
     */
63 11
    protected function getDefaultInputDefinition(): InputDefinition
64
    {
65 11
        return new InputDefinition(
66 11
            [
67 11
                new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
68 11
                new InputOption(
69 11
                    '--env',
70 11
                    '-e',
71 11
                    InputOption::VALUE_REQUIRED,
72
                    'The environment to be used',
73 11
                    getenv('BLUZ_ENV') ?: 'dev'
74 11
                ),
75 11
                new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
76 11
                new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
77
                new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages'),
78
                new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version')
79
            ]
80
        );
81
    }
82
83
    /**
84
     * Register Bluzman commands
85
     *
86 15
     * @todo Find a way to do this automatically or move it to /bin/bluzman
87
     */
88 15
    protected function registerCommands()
89
    {
90 15
        $this->addCommands(
91 15
            [
92 15
                new Command\MagicCommand(),
93 15
                new Command\RunCommand(),
94 15
                new Command\TestCommand(),
95 15
                new Command\Db\CreateCommand(),
96 15
                new Command\Db\MigrateCommand(),
97 15
                new Command\Db\RollbackCommand(),
98 15
                new Command\Db\StatusCommand(),
99 15
                new Command\Db\SeedCreateCommand(),
100 15
                new Command\Db\SeedRunCommand(),
101 15
                new Command\Generate\ModuleCommand(),
102 15
                new Command\Generate\ControllerCommand(),
103 15
                new Command\Generate\ModelCommand(),
104 15
                new Command\Generate\CrudCommand(),
105 15
                new Command\Generate\GridCommand(),
106 15
                new Command\Generate\RestCommand(),
107 15
                new Command\Generate\ScaffoldCommand(),
108 15
                new Command\Module\InstallCommand(),
109 15
                new Command\Module\ListCommand(),
110 15
                new Command\Module\RemoveCommand(),
111 15
                new Command\Server\StartCommand(),
112
                new Command\Server\StopCommand(),
113
                new Command\Server\StatusCommand(),
114 15
            ]
115
        );
116
    }
117
118
    /**
119
     * Returns the path to the directory with bluzman application
120
     *
121
     * @return string
122
     */
123
    public function getWorkingPath(): string
124
    {
125
        return getcwd();
126
    }
127
128
    /**
129
     * Get Module path
130
     *
131
     * @param string $name
132 4
     * @return string
133
     */
134 4
    public function getModulePath(string $name): string
135 4
    {
136 4
        return $this->getWorkingPath() . DIRECTORY_SEPARATOR
137 4
            . 'application' . DIRECTORY_SEPARATOR
138
            . 'modules' . DIRECTORY_SEPARATOR
139
            . $name;
140
    }
141
142
    /**
143
     * Get Model path
144
     *
145
     * @param string $name
146 5
     * @return string
147
     */
148 5
    public function getModelPath(string $name): string
149 5
    {
150 5
        return $this->getWorkingPath() . DIRECTORY_SEPARATOR
151 5
            . 'application' . DIRECTORY_SEPARATOR
152
            . 'models' . DIRECTORY_SEPARATOR
153
            . ucfirst(strtolower($name));
154
    }
155
156
    /**
157
     * @param string $name
158
     * @return bool
159
     */
160
    public function isModuleExists(string $name): bool
161
    {
162
        return is_dir($this->getModulePath($name));
163
    }
164
165
    /**
166
     * @param string $name
167
     * @return bool
168
     */
169
    public function isModelExists(string $name): bool
170
    {
171
        return is_dir($this->getModelPath($name));
172
    }
173
}
174