@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function getPrefixByMagnitude(int $magnitude) : array |
| 57 | 57 | { |
| 58 | - $prefixes_pos = ['' ,'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; |
|
| 59 | - $prefixes_neg = ['' ,'m', 'μ', 'n', 'p', 'f', 'a', 'z', 'y']; |
|
| 58 | + $prefixes_pos = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; |
|
| 59 | + $prefixes_neg = ['', 'm', 'μ', 'n', 'p', 'f', 'a', 'z', 'y']; |
|
| 60 | 60 | |
| 61 | 61 | //Determine nearest prefix index. |
| 62 | 62 | $nearest = (int) round(abs($magnitude) / 3); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | [$divisor, $symbol] = $this->getPrefixByMagnitude($this->getMagnitude($value)); |
| 86 | 86 | $value /= $divisor; |
| 87 | 87 | //Build the format string, e.g.: %.2d km |
| 88 | - $format_string = '%.' . $decimals . 'f ' . $symbol . $unit; |
|
| 88 | + $format_string = '%.'.$decimals.'f '.$symbol.$unit; |
|
| 89 | 89 | |
| 90 | 90 | return sprintf($format_string, $value); |
| 91 | 91 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function getIDString(): string |
| 117 | 117 | { |
| 118 | - return 'PL' . $this->getID(); |
|
| 118 | + return 'PL'.$this->getID(); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | public function setAmount(float $new_amount): PartLot |
| 270 | 270 | { |
| 271 | - $this->amount = $new_amount; |
|
| 271 | + $this->amount = $new_amount; |
|
| 272 | 272 | return $this; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | |
| 79 | 79 | /* If any group change, then invalidate all cached trees. Users Permissions can be inherited from groups, |
| 80 | 80 | so a change in any group can cause big permisssion changes for users. So to be sure, invalidate all trees */ |
| 81 | - if($element instanceof Group) { |
|
| 81 | + if ($element instanceof Group) { |
|
| 82 | 82 | $tag = "groups"; |
| 83 | 83 | $this->cache->invalidateTags([$tag]); |
| 84 | 84 | } |
@@ -64,10 +64,10 @@ |
||
| 64 | 64 | //If the user is null, then treat it as anonymous user. |
| 65 | 65 | //When the anonymous user is passed as user then use this path too. |
| 66 | 66 | if ($user === null || $user->getID() === User::ID_ANONYMOUS) { |
| 67 | - return 'user$_' . User::ID_ANONYMOUS; |
|
| 67 | + return 'user$_'.User::ID_ANONYMOUS; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | //In the most cases we can just use the username (its unique) |
| 71 | - return "user_" . $user->getUsername(); |
|
| 71 | + return "user_".$user->getUsername(); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | \ No newline at end of file |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | $tree_node = new TreeViewNode($element->__toString(), $href, $children_nodes); |
| 104 | 104 | |
| 105 | - if($children_nodes != null) { |
|
| 105 | + if ($children_nodes != null) { |
|
| 106 | 106 | $tree_node->addTag((string) count($children_nodes)); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | $parent_id = $parent != null ? $parent->getID() : "0"; |
| 178 | 178 | // Backslashes are not allowed in cache keys |
| 179 | 179 | $secure_class_name = str_replace("\\", '_', $class_name); |
| 180 | - $key = "list_" . $this->keyGenerator->generateKey() . "_" . $secure_class_name . $parent_id; |
|
| 180 | + $key = "list_".$this->keyGenerator->generateKey()."_".$secure_class_name.$parent_id; |
|
| 181 | 181 | |
| 182 | - $ret = $this->cache->get($key, function (ItemInterface $item) use ($class_name, $parent, $secure_class_name) { |
|
| 182 | + $ret = $this->cache->get($key, function(ItemInterface $item) use ($class_name, $parent, $secure_class_name) { |
|
| 183 | 183 | // Invalidate when groups, a element with the class or the user changes |
| 184 | 184 | $item->tag(['groups', 'tree_list', $this->keyGenerator->generateKey(), $secure_class_name]); |
| 185 | 185 | /** |
@@ -66,9 +66,9 @@ |
||
| 66 | 66 | */ |
| 67 | 67 | public function getTree() : array |
| 68 | 68 | { |
| 69 | - $key = "tree_tools_" . $this->keyGenerator->generateKey(); |
|
| 69 | + $key = "tree_tools_".$this->keyGenerator->generateKey(); |
|
| 70 | 70 | |
| 71 | - return $this->cache->get($key, function (ItemInterface $item) { |
|
| 71 | + return $this->cache->get($key, function(ItemInterface $item) { |
|
| 72 | 72 | //Invalidate tree, whenever group or the user changes |
| 73 | 73 | $item->tag(["tree_tools", "groups", $this->keyGenerator->generateKey()]); |
| 74 | 74 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $resolver->setDefaults([ |
| 60 | 60 | 'measurement_unit' => null, |
| 61 | - 'show_prefix' => function (Options $options) { |
|
| 61 | + 'show_prefix' => function(Options $options) { |
|
| 62 | 62 | if ($options['measurement_unit'] !== null) { |
| 63 | 63 | /** @var MeasurementUnit $unit */ |
| 64 | 64 | $unit = $options['measurement_unit']; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | return false; |
| 68 | 68 | }, |
| 69 | - 'is_integer' => function (Options $options) { |
|
| 69 | + 'is_integer' => function(Options $options) { |
|
| 70 | 70 | if ($options['measurement_unit'] !== null) { |
| 71 | 71 | /** @var MeasurementUnit $unit */ |
| 72 | 72 | $unit = $options['measurement_unit']; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | return false; |
| 76 | 76 | }, |
| 77 | - 'unit' => function (Options $options) { |
|
| 77 | + 'unit' => function(Options $options) { |
|
| 78 | 78 | if ($options['measurement_unit'] !== null) { |
| 79 | 79 | /** @var MeasurementUnit $unit */ |
| 80 | 80 | $unit = $options['measurement_unit']; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | return null; |
| 84 | 84 | }, |
| 85 | - 'error_mapping' => [ '.' => 'value'] |
|
| 85 | + 'error_mapping' => ['.' => 'value'] |
|
| 86 | 86 | ]); |
| 87 | 87 | |
| 88 | 88 | $resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $resolver->setDefaults([ |
| 93 | 93 | 'min' => 0, |
| 94 | 94 | 'max' => '', |
| 95 | - 'step' => function (Options $options) { |
|
| 95 | + 'step' => function(Options $options) { |
|
| 96 | 96 | if ($options['is_integer'] === true) { |
| 97 | 97 | return 1; |
| 98 | 98 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if ($options['show_prefix']) { |
| 119 | 119 | $builder->add('prefix', ChoiceType::class, [ |
| 120 | - 'choices' => ['M' => 6, 'k' => 3, '' => 0, 'm' => -3, 'µ' => -6 ] |
|
| 120 | + 'choices' => ['M' => 6, 'k' => 3, '' => 0, 'm' => -3, 'µ' => -6] |
|
| 121 | 121 | ]); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | if ($fs->isAbsolutePath($tmp_base_path)) { |
| 58 | 58 | $this->base_path = $tmp_base_path; |
| 59 | 59 | } else { |
| 60 | - $this->base_path = realpath($kernel->getProjectDir() . DIRECTORY_SEPARATOR . $tmp_base_path); |
|
| 60 | + $this->base_path = realpath($kernel->getProjectDir().DIRECTORY_SEPARATOR.$tmp_base_path); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $sz = 'BKMGTP'; |
| 161 | 161 | $factor = (int) floor((strlen($bytes) - 1) / 3); |
| 162 | - return sprintf("%.{$decimals}f", $bytes / 1024 ** $factor) . @$sz[$factor]; |
|
| 162 | + return sprintf("%.{$decimals}f", $bytes / 1024 ** $factor).@$sz[$factor]; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $mapping = [PartAttachment::class => 'part']; |
| 173 | 173 | |
| 174 | - $path = $this->base_path . DIRECTORY_SEPARATOR . $mapping[get_class($attachment)] . DIRECTORY_SEPARATOR . $attachment->getElement()->getID(); |
|
| 174 | + $path = $this->base_path.DIRECTORY_SEPARATOR.$mapping[get_class($attachment)].DIRECTORY_SEPARATOR.$attachment->getElement()->getID(); |
|
| 175 | 175 | return $path; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -193,17 +193,17 @@ discard block |
||
| 193 | 193 | //Sanatize filename |
| 194 | 194 | $originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME); |
| 195 | 195 | $safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename); |
| 196 | - $newFilename = $safeFilename . '.' . $file->getClientOriginalExtension(); |
|
| 196 | + $newFilename = $safeFilename.'.'.$file->getClientOriginalExtension(); |
|
| 197 | 197 | |
| 198 | 198 | //If a file with this name is already existing add a number to the filename |
| 199 | - if (file_exists($folder . DIRECTORY_SEPARATOR . $newFilename)) { |
|
| 199 | + if (file_exists($folder.DIRECTORY_SEPARATOR.$newFilename)) { |
|
| 200 | 200 | $bak = $newFilename; |
| 201 | 201 | |
| 202 | 202 | $number = 1; |
| 203 | - $newFilename = $folder . DIRECTORY_SEPARATOR . $safeFilename . '-' . $number . '.' . $file->getClientOriginalExtension(); |
|
| 203 | + $newFilename = $folder.DIRECTORY_SEPARATOR.$safeFilename.'-'.$number.'.'.$file->getClientOriginalExtension(); |
|
| 204 | 204 | while (file_exists($newFilename)) { |
| 205 | 205 | $number++; |
| 206 | - $newFilename = $folder . DIRECTORY_SEPARATOR . $safeFilename . '-' . $number . '.' . $file->getClientOriginalExtension(); |
|
| 206 | + $newFilename = $folder.DIRECTORY_SEPARATOR.$safeFilename.'-'.$number.'.'.$file->getClientOriginalExtension(); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $io = new SymfonyStyle($input, $output); |
| 47 | 47 | |
| 48 | 48 | $mediaPath = $this->attachment_helper->getMediaPath(); |
| 49 | - $io->note("The media path is " . $mediaPath); |
|
| 49 | + $io->note("The media path is ".$mediaPath); |
|
| 50 | 50 | |
| 51 | 51 | $finder = new Finder(); |
| 52 | 52 | //We look for files in the media folder only |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function removeEmptySubFolders($path) |
| 105 | 105 | { |
| 106 | - $empty=true; |
|
| 107 | - foreach (glob($path . DIRECTORY_SEPARATOR . "*") as $file) |
|
| 106 | + $empty = true; |
|
| 107 | + foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file) |
|
| 108 | 108 | { |
| 109 | 109 | $empty &= is_dir($file) && $this->removeEmptySubFolders($file); |
| 110 | 110 | } |