1 | <?php |
||
36 | trait CommonBasic |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * Moves files into another folder |
||
41 | * |
||
42 | * @param type $sourcePath |
||
43 | * @param type $targetPath |
||
44 | * @return type |
||
45 | */ |
||
46 | protected function moveFilesIntoTargetFolder($sourcePath, $targetPath) |
||
47 | { |
||
48 | $filesystem = new \Symfony\Component\Filesystem\Filesystem(); |
||
49 | $filesystem->mirror($sourcePath, $targetPath); |
||
50 | $finder = new \Symfony\Component\Finder\Finder(); |
||
51 | $iterator = $finder->files()->ignoreUnreadableDirs(true)->followLinks()->in($sourcePath); |
||
52 | $sFiles = []; |
||
53 | foreach ($iterator as $file) { |
||
54 | $relativePathFile = str_replace($sourcePath, '', $file->getRealPath()); |
||
55 | if (!file_exists($targetPath . $relativePathFile)) { |
||
56 | $sFiles[$relativePathFile] = $targetPath . $relativePathFile; |
||
57 | } |
||
58 | } |
||
59 | return $this->setArrayToJson($sFiles); |
||
60 | } |
||
61 | |||
62 | protected function removeFilesDecision($inputArray) |
||
63 | { |
||
64 | $proceedWithDeletion = false; |
||
65 | if (is_array($inputArray)) { |
||
66 | if (!isset($inputArray['path'])) { |
||
67 | return '`path` has not been provided'; |
||
68 | } elseif (!isset($inputArray['dateRule'])) { |
||
69 | return '`dateRule` has not been provided'; |
||
70 | } |
||
71 | $proceedWithDeletion = true; |
||
72 | } |
||
73 | return $proceedWithDeletion; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Remove files older than given rule |
||
78 | * (both Access time and Modified time will be checked |
||
79 | * and only if both matches removal will take place) |
||
80 | * |
||
81 | * @param array $inputArray |
||
82 | * @return string |
||
83 | */ |
||
84 | protected function removeFilesOlderThanGivenRule($inputArray) |
||
94 | |||
95 | protected function retrieveFilesOlderThanGivenRule($inputArray) |
||
111 | |||
112 | /** |
||
113 | * Replace space with break line for each key element |
||
114 | * |
||
115 | * @param array $aElements |
||
116 | * @return array |
||
117 | */ |
||
118 | protected function setArrayToArrayKbr(array $aElements) |
||
126 | |||
127 | /** |
||
128 | * Converts a single-child array into an parent-child one |
||
129 | * |
||
130 | * @param type $inArray |
||
131 | * @return type |
||
132 | */ |
||
133 | protected function setArrayValuesAsKey(array $inArray) |
||
139 | |||
140 | /** |
||
141 | * Converts an array into JSON string |
||
142 | * |
||
143 | * @param array $inArray |
||
144 | * @return string |
||
145 | */ |
||
146 | protected function setArrayToJson(array $inArray) |
||
156 | |||
157 | /** |
||
158 | * Provides a list of all known JSON errors and their description |
||
159 | * |
||
160 | * @return type |
||
161 | */ |
||
162 | protected function setJsonErrorInPlainEnglish() |
||
179 | } |
||
180 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
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.