Conditions | 6 |
Paths | 64 |
Total Lines | 59 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
67 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
68 | { |
||
69 | $io = new SymfonyStyle(input: $input, output: $output); |
||
70 | |||
71 | $data = '; <?php return; ?> DO NOT DELETE THIS LINE' . PHP_EOL; |
||
72 | |||
73 | $config = [ |
||
74 | 'dbtype' => $this->stringOption(input: $input, name: 'dbtype'), |
||
75 | 'dbhost' => $this->stringOption(input: $input, name: 'dbhost'), |
||
76 | 'dbport' => $this->stringOption(input: $input, name: 'dbport'), |
||
77 | 'dbuser' => $this->stringOption(input: $input, name: 'dbuser'), |
||
78 | 'dbpass' => $this->stringOption(input: $input, name: 'dbpass'), |
||
79 | 'dbname' => $this->stringOption(input: $input, name: 'dbname'), |
||
80 | 'dbkey' => $this->stringOption(input: $input, name: 'dbkey'), |
||
81 | 'dbcert' => $this->stringOption(input: $input, name: 'dbcert'), |
||
82 | 'dbca' => $this->stringOption(input: $input, name: 'dbca'), |
||
83 | 'dbverify' => $this->boolOption(input: $input, name: 'dbverify') ? '1' : '0', |
||
84 | 'tblpfx' => $this->stringOption(input: $input, name: 'tblpfx'), |
||
85 | 'base_url' => rtrim(string: $this->stringOption(input: $input, name: 'base-url'), characters: '/'), |
||
86 | 'rewrite_urls' => $this->boolOption(input: $input, name: 'rewrite-urls') ? '1' : '0', |
||
87 | 'block_asn' => $this->stringOption(input: $input, name: 'block-asn'), |
||
88 | ]; |
||
89 | |||
90 | foreach ($config as $key => $value) { |
||
91 | $data .= $key . ' = "' . addcslashes(string: $value, characters: '"') . '"' . PHP_EOL; |
||
92 | } |
||
93 | |||
94 | $io->info(message: $data); |
||
95 | file_put_contents(filename: Webtrees::CONFIG_FILE, data: $data); |
||
96 | |||
97 | if ($config['base_url'] === '') { |
||
98 | $io->warning(message: 'You must set the base URL'); |
||
99 | } |
||
100 | |||
101 | try { |
||
102 | $config = parse_ini_file(filename: Webtrees::CONFIG_FILE); |
||
103 | |||
104 | DB::connect( |
||
105 | driver: $config['dbtype'], |
||
106 | host: $config['dbhost'], |
||
107 | port: $config['dbport'], |
||
108 | database: $config['dbname'], |
||
109 | username: $config['dbuser'], |
||
110 | password: $config['dbpass'], |
||
111 | prefix: $config['tblpfx'], |
||
112 | key: $config['dbkey'], |
||
113 | certificate: $config['dbcert'], |
||
114 | ca: $config['dbca'], |
||
115 | verify_certificate: (bool) $config['dbverify'], |
||
116 | ); |
||
117 | |||
118 | $io->success(message: 'Database connection successful'); |
||
119 | } catch (Throwable $ex) { |
||
120 | $io->error(message: 'Database connection failed: ' . $ex->getMessage()); |
||
121 | |||
122 | return self::FAILURE; |
||
123 | } |
||
124 | |||
125 | return self::SUCCESS; |
||
126 | } |
||
128 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths