Conditions | 8 |
Paths | 13 |
Total Lines | 57 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
87 | public function process(string $input, string $output, array $options = []) |
||
88 | { |
||
89 | $options = $this->parseProcessOptions($options); |
||
90 | |||
91 | if (!$input) { |
||
92 | throw new \PHPJasper\Exception\InvalidInputFile(); |
||
93 | } |
||
94 | |||
95 | $this->validateFormat($options['format']); |
||
96 | |||
97 | $this->command = $this->checkServer(); |
||
98 | |||
99 | if ($options['locale']) { |
||
100 | $this->command .= " --locale {$options['locale']}"; |
||
101 | } |
||
102 | |||
103 | $this->command .= ' process '; |
||
104 | $this->command .= "\"$input\""; |
||
105 | $this->command .= ' -o ' . "\"$output\""; |
||
106 | |||
107 | $this->command .= ' -f ' . join(' ', $options['format']); |
||
108 | if ($options['params']) { |
||
109 | $this->command .= ' -P '; |
||
110 | foreach ($options['params'] as $key => $value) { |
||
111 | $this->command .= " " . $key . '="' . $value . '" ' . " "; |
||
112 | } |
||
113 | } |
||
114 | |||
115 | if ($options['db_connection']) { |
||
116 | $mapDbParams = [ |
||
117 | 'driver' => '-t', |
||
118 | 'username' => '-u', |
||
119 | 'password' => '-p', |
||
120 | 'host' => '-H', |
||
121 | 'database' => '-n', |
||
122 | 'port' => '--db-port', |
||
123 | 'jdbc_driver' => '--db-driver', |
||
124 | 'jdbc_url' => '--db-url', |
||
125 | 'jdbc_dir' => '--jdbc-dir', |
||
126 | 'db_sid' => '-db-sid', |
||
127 | 'xml_xpath' => '--xml-xpath', |
||
128 | 'data_file' => '--data-file', |
||
129 | 'json_query' => '--json-query' |
||
130 | ]; |
||
131 | |||
132 | foreach ($options['db_connection'] as $key => $value) { |
||
133 | $this->command .= " {$mapDbParams[$key]} {$value}"; |
||
134 | } |
||
135 | |||
136 | if ($options['resources']) { |
||
137 | $this->command .= " -r {$options['resources']}"; |
||
138 | } |
||
139 | |||
140 | $this->command = $this->command . ' 2>&1'; |
||
141 | } |
||
142 | |||
143 | return $this; |
||
144 | } |
||
254 |