Conditions | 8 |
Paths | 32 |
Total Lines | 57 |
Code Lines | 35 |
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 |
||
82 | public function readData($option): array { |
||
83 | include_once __DIR__ . '/../../vendor/autoload.php'; |
||
84 | $header = $dataClean = $data = array(); |
||
85 | $headerrow = $error = 0; |
||
86 | |||
87 | $file = $this->rootFolder->getUserFolder($option['user_id'])->get($option['link']); |
||
88 | $fileName = $file->getStorage()->getLocalFile($file->getInternalPath()); |
||
89 | |||
90 | $inputFileType = IOFactory::identify($fileName); |
||
91 | $reader = IOFactory::createReader($inputFileType); |
||
92 | //$reader->setReadDataOnly(true); disabled as idDate is not working otherwise |
||
93 | if (strlen($option['sheet']) > 0) { |
||
94 | $reader->setLoadSheetsOnly([$option['sheet']]); |
||
95 | } |
||
96 | $spreadsheet = $reader->load($fileName); |
||
97 | |||
98 | // separated columns can be selected via ranges e.g. "A1:B9,C1:C9" |
||
99 | // these ranges are read and linked |
||
100 | $ranges = str_getcsv($option['range']); |
||
101 | foreach ($ranges as $range) { |
||
102 | $values = $spreadsheet->getActiveSheet()->rangeToArray($range, // The worksheet range that we want to retrieve |
||
103 | null, // Value that should be returned for empty cells |
||
104 | true, // Should formulas be calculated (the equivalent of getCalculatedValue() for each cell) |
||
105 | true, // Should values be formatted (the equivalent of getFormattedValue() for each cell) |
||
106 | false // Should the array be indexed by cell row and cell column |
||
107 | ); |
||
108 | |||
109 | $values = $this->convertExcelDate($spreadsheet, $values, $range); |
||
110 | |||
111 | if (empty($data)) { |
||
112 | // first range will fill the array with all rows |
||
113 | $data = $values; |
||
114 | } else { |
||
115 | // further columns will be attached to the first ones |
||
116 | foreach ($data as $key => $value) { |
||
117 | $data[$key] = array_merge($value, $values[$key]); |
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | |||
122 | // Remove columns that are completely null |
||
123 | $data = $this->removeNullColumns($data); |
||
124 | |||
125 | foreach ($data as $key => $value) { |
||
126 | if ($headerrow === 0) { |
||
127 | $header = array_values($value); |
||
128 | $headerrow = 1; |
||
129 | } else if (!$this->containsOnlyNull($value)) { |
||
130 | array_push($dataClean, array_values($value)); |
||
131 | } |
||
132 | } |
||
133 | |||
134 | return [ |
||
135 | 'header' => $header, |
||
136 | 'dimensions' => array_slice($header, 0, count($header) - 1), |
||
137 | 'data' => $dataClean, |
||
138 | 'error' => $error, |
||
139 | ]; |
||
206 | } |
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