@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public static function getPresetsManager() : PresetsManager |
| 43 | 43 | { |
| 44 | - if(!isset(self::$presets)) |
|
| 44 | + if (!isset(self::$presets)) |
|
| 45 | 45 | { |
| 46 | 46 | self::$presets = new PresetsManager(); |
| 47 | 47 | } |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * @param string $name |
| 58 | 58 | * @return RGBAColor |
| 59 | 59 | */ |
| 60 | - public static function create(ColorChannel $red, ColorChannel $green, ColorChannel $blue, ?ColorChannel $alpha=null, string $name='') : RGBAColor |
|
| 60 | + public static function create(ColorChannel $red, ColorChannel $green, ColorChannel $blue, ?ColorChannel $alpha = null, string $name = '') : RGBAColor |
|
| 61 | 61 | { |
| 62 | - if($alpha === null) |
|
| 62 | + if ($alpha === null) |
|
| 63 | 63 | { |
| 64 | 64 | $alpha = ColorChannel::eightBit(0); |
| 65 | 65 | } |
@@ -86,31 +86,31 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public static function createAuto($subject) : ?RGBAColor |
| 88 | 88 | { |
| 89 | - if($subject instanceof RGBAColor) |
|
| 89 | + if ($subject instanceof RGBAColor) |
|
| 90 | 90 | { |
| 91 | 91 | return $subject; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if(is_array($subject)) |
|
| 94 | + if (is_array($subject)) |
|
| 95 | 95 | { |
| 96 | 96 | return self::createFrom8BitArray($subject); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $hexOrPreset = (string)$subject; |
| 100 | 100 | |
| 101 | - if($hexOrPreset === '') |
|
| 101 | + if ($hexOrPreset === '') |
|
| 102 | 102 | { |
| 103 | 103 | return null; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $manager = self::getPresetsManager(); |
| 107 | 107 | |
| 108 | - if($manager->hasPreset($hexOrPreset)) |
|
| 108 | + if ($manager->hasPreset($hexOrPreset)) |
|
| 109 | 109 | { |
| 110 | 110 | return $manager->getPreset($hexOrPreset); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if(preg_match('/[a-f0-9]{3,8}/i', $hexOrPreset)) |
|
| 113 | + if (preg_match('/[a-f0-9]{3,8}/i', $hexOrPreset)) |
|
| 114 | 114 | { |
| 115 | 115 | return self::createFromHEX($hexOrPreset); |
| 116 | 116 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $color = FormatsConverter::array2associative($color); |
| 160 | 160 | |
| 161 | - if(!isset($color[RGBAColor::CHANNEL_ALPHA])) |
|
| 161 | + if (!isset($color[RGBAColor::CHANNEL_ALPHA])) |
|
| 162 | 162 | { |
| 163 | 163 | $color[RGBAColor::CHANNEL_ALPHA] = 0; |
| 164 | 164 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @see RGBAColor::ERROR_INVALID_COLOR_COMPONENT |
| 184 | 184 | * @see RGBAColor::ERROR_INVALID_PERCENTAGE_VALUE |
| 185 | 185 | */ |
| 186 | - public static function createFromHEX(string $hex, string $name='') : RGBAColor |
|
| 186 | + public static function createFromHEX(string $hex, string $name = '') : RGBAColor |
|
| 187 | 187 | { |
| 188 | 188 | return FormatsConverter::hex2color($hex, $name); |
| 189 | 189 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param string $name |
| 209 | 209 | * @return RGBAColor |
| 210 | 210 | */ |
| 211 | - public static function createPercent(float $red, float $green, float $blue, float $alpha=0, string $name='') : RGBAColor |
|
| 211 | + public static function createPercent(float $red, float $green, float $blue, float $alpha = 0, string $name = '') : RGBAColor |
|
| 212 | 212 | { |
| 213 | 213 | return new RGBAColor( |
| 214 | 214 | ColorChannel::percent($red), |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @param string $name |
| 231 | 231 | * @return RGBAColor |
| 232 | 232 | */ |
| 233 | - public static function createCSS(int $red, int $green, int $blue, float $alpha=0, string $name='') : RGBAColor |
|
| 233 | + public static function createCSS(int $red, int $green, int $blue, float $alpha = 0, string $name = '') : RGBAColor |
|
| 234 | 234 | { |
| 235 | 235 | return self::create( |
| 236 | 236 | ColorChannel::eightBit($red), |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param string $name |
| 253 | 253 | * @return RGBAColor |
| 254 | 254 | */ |
| 255 | - public static function create8Bit(int $red, int $green, int $blue, int $alpha=0, string $name='') : RGBAColor |
|
| 255 | + public static function create8Bit(int $red, int $green, int $blue, int $alpha = 0, string $name = '') : RGBAColor |
|
| 256 | 256 | { |
| 257 | 257 | return self::create( |
| 258 | 258 | ColorChannel::eightBit($red), |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @param string $name |
| 276 | 276 | * @return RGBAColor |
| 277 | 277 | */ |
| 278 | - public static function createGD(int $red, int $green, int $blue, int $alpha=0, string $name='') : RGBAColor |
|
| 278 | + public static function createGD(int $red, int $green, int $blue, int $alpha = 0, string $name = '') : RGBAColor |
|
| 279 | 279 | { |
| 280 | 280 | return self::create( |
| 281 | 281 | ColorChannel::eightBit($red), |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | $color = imagecolorsforindex($img, $colorIndex); |
| 298 | 298 | |
| 299 | 299 | // it seems imagecolorsforindex() may return false (undocumented, unproven) |
| 300 | - if(is_array($color)) { |
|
| 300 | + if (is_array($color)) { |
|
| 301 | 301 | return self::create( |
| 302 | 302 | ColorChannel::eightBit($color['red']), |
| 303 | 303 | ColorChannel::eightBit($color['green']), |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function init() : void |
| 64 | 64 | { |
| 65 | - if(self::$initialized === true) |
|
| 65 | + if (self::$initialized === true) |
|
| 66 | 66 | { |
| 67 | 67 | return; |
| 68 | 68 | } |
@@ -89,16 +89,16 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $preset = null; |
| 91 | 91 | |
| 92 | - if(isset($this->customPresets[$name])) |
|
| 92 | + if (isset($this->customPresets[$name])) |
|
| 93 | 93 | { |
| 94 | 94 | $preset = $this->customPresets[$name]; |
| 95 | 95 | } |
| 96 | - else if(isset(self::$globalPresets[$name])) |
|
| 96 | + else if (isset(self::$globalPresets[$name])) |
|
| 97 | 97 | { |
| 98 | 98 | $preset = self::$globalPresets[$name]; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if($preset !== null) |
|
| 101 | + if ($preset !== null) |
|
| 102 | 102 | { |
| 103 | 103 | return ColorFactory::create( |
| 104 | 104 | ColorChannel::eightBit($preset[RGBAColor::CHANNEL_RED]), |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $this->requireNotGlobal($name); |
| 134 | 134 | |
| 135 | - if(!isset(self::$globalPresets[$name])) |
|
| 135 | + if (!isset(self::$globalPresets[$name])) |
|
| 136 | 136 | { |
| 137 | 137 | self::$globalPresets[$name] = array( |
| 138 | 138 | RGBAColor::CHANNEL_RED => $red, |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | ); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function registerPreset(string $name, int $red, int $green, int $blue, int $alpha=255) : PresetsManager |
|
| 157 | + public function registerPreset(string $name, int $red, int $green, int $blue, int $alpha = 255) : PresetsManager |
|
| 158 | 158 | { |
| 159 | 159 | $this->requireNotGlobal($name); |
| 160 | 160 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | private function requireNotGlobal(string $name) : void |
| 172 | 172 | { |
| 173 | - if(!isset(self::$globalPresets[$name])) |
|
| 173 | + if (!isset(self::$globalPresets[$name])) |
|
| 174 | 174 | { |
| 175 | 175 | return; |
| 176 | 176 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | public static function color2HEX(RGBAColor $color) : string |
| 41 | 41 | { |
| 42 | 42 | $hex = |
| 43 | - UnitsConverter::int2hex($color->getRed()->get8Bit()) . |
|
| 44 | - UnitsConverter::int2hex($color->getGreen()->get8Bit()) . |
|
| 43 | + UnitsConverter::int2hex($color->getRed()->get8Bit()). |
|
| 44 | + UnitsConverter::int2hex($color->getGreen()->get8Bit()). |
|
| 45 | 45 | UnitsConverter::int2hex($color->getBlue()->get8Bit()); |
| 46 | 46 | |
| 47 | - if($color->hasTransparency()) |
|
| 47 | + if ($color->hasTransparency()) |
|
| 48 | 48 | { |
| 49 | 49 | $hex .= UnitsConverter::int2hex($color->getAlpha()->get8Bit()); |
| 50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public static function color2CSS(RGBAColor $color) : string |
| 62 | 62 | { |
| 63 | - if($color->hasTransparency()) |
|
| 63 | + if ($color->hasTransparency()) |
|
| 64 | 64 | { |
| 65 | 65 | return sprintf( |
| 66 | 66 | 'rgba(%s, %s, %s, %s)', |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public static function requireValidColorArray(array $color) : void |
| 97 | 97 | { |
| 98 | - if(self::isColorArray($color)) |
|
| 98 | + if (self::isColorArray($color)) |
|
| 99 | 99 | { |
| 100 | 100 | return; |
| 101 | 101 | } |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | RGBAColor::CHANNEL_BLUE |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - foreach($keys as $key) |
|
| 130 | + foreach ($keys as $key) |
|
| 131 | 131 | { |
| 132 | - if(!isset($color[$key])) |
|
| 132 | + if (!isset($color[$key])) |
|
| 133 | 133 | { |
| 134 | 134 | return false; |
| 135 | 135 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public static function color2readable(RGBAColor $color) : string |
| 150 | 150 | { |
| 151 | - if($color->hasTransparency()) |
|
| 151 | + if ($color->hasTransparency()) |
|
| 152 | 152 | { |
| 153 | 153 | return sprintf( |
| 154 | 154 | 'RGBA(%s %s %s %s)', |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | * @throws ColorException |
| 192 | 192 | * @see RGBAColor::ERROR_INVALID_HEX_LENGTH |
| 193 | 193 | */ |
| 194 | - public static function hex2color(string $hex, string $name='') : RGBAColor |
|
| 194 | + public static function hex2color(string $hex, string $name = '') : RGBAColor |
|
| 195 | 195 | { |
| 196 | - if(!isset(self::$hexParser)) |
|
| 196 | + if (!isset(self::$hexParser)) |
|
| 197 | 197 | { |
| 198 | 198 | self::$hexParser = new HEXParser(); |
| 199 | 199 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | // If one associative key is present, we assume |
| 247 | 247 | // that the color array is already correct. |
| 248 | - if(isset($color[RGBAColor::CHANNEL_RED])) |
|
| 248 | + if (isset($color[RGBAColor::CHANNEL_RED])) |
|
| 249 | 249 | { |
| 250 | 250 | return $color; |
| 251 | 251 | } |
@@ -253,15 +253,15 @@ discard block |
||
| 253 | 253 | $values = array_values($color); |
| 254 | 254 | $result = array(); |
| 255 | 255 | |
| 256 | - foreach(self::$keys as $idx => $def) |
|
| 256 | + foreach (self::$keys as $idx => $def) |
|
| 257 | 257 | { |
| 258 | - if(isset($values[$idx])) |
|
| 258 | + if (isset($values[$idx])) |
|
| 259 | 259 | { |
| 260 | 260 | $result[$def['key']] = $values[$idx]; |
| 261 | 261 | continue; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if(!$def['mandatory']) |
|
| 264 | + if (!$def['mandatory']) |
|
| 265 | 265 | { |
| 266 | 266 | continue; |
| 267 | 267 | } |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | return (int)floor( |
| 119 | 119 | ( |
| 120 | - ($this->getRed()->get8Bit()*2) |
|
| 120 | + ($this->getRed()->get8Bit() * 2) |
|
| 121 | 121 | + |
| 122 | 122 | $this->getBlue()->get8Bit() |
| 123 | 123 | + |
| 124 | - ($this->getGreen()->get8Bit()*3) |
|
| 124 | + ($this->getGreen()->get8Bit() * 3) |
|
| 125 | 125 | ) |
| 126 | 126 | /6 |
| 127 | 127 | ); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | private function requireValidComponent(string $name) : void |
| 370 | 370 | { |
| 371 | - if(in_array($name, self::COLOR_COMPONENTS)) |
|
| 371 | + if (in_array($name, self::COLOR_COMPONENTS)) |
|
| 372 | 372 | { |
| 373 | 373 | return; |
| 374 | 374 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | return $this->setOption('separatorChar', $char); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function setTrailingNewline(bool $useNewline=true) : self |
|
| 49 | + public function setTrailingNewline(bool $useNewline = true) : self |
|
| 50 | 50 | { |
| 51 | 51 | return $this->setOption('trailingNewline', $useNewline); |
| 52 | 52 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $args = $args[0]; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $this->lines[] = '"' . implode('"'.$this->getOption('separatorChar').'"', $args) . '"'; |
|
| 67 | + $this->lines[] = '"'.implode('"'.$this->getOption('separatorChar').'"', $args).'"'; |
|
| 68 | 68 | |
| 69 | 69 | return $this; |
| 70 | 70 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | $csv = implode(PHP_EOL, $this->lines); |
| 82 | 82 | |
| 83 | - if($this->getOption('trailingNewline')) { |
|
| 83 | + if ($this->getOption('trailingNewline')) { |
|
| 84 | 84 | $csv .= PHP_EOL; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function setOption(string $name, $value) : self |
| 96 | 96 | { |
| 97 | - if(!isset($this->options)) { |
|
| 97 | + if (!isset($this->options)) { |
|
| 98 | 98 | $this->options = $this->getDefaultOptions(); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function setOptions(array $options) : self |
| 110 | 110 | { |
| 111 | - foreach($options as $name => $value) { |
|
| 111 | + foreach ($options as $name => $value) { |
|
| 112 | 112 | $this->setOption($name, $value); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | * @param mixed|NULL $default |
| 121 | 121 | * @return mixed|NULL |
| 122 | 122 | */ |
| 123 | - public function getOption(string $name, $default=null) |
|
| 123 | + public function getOption(string $name, $default = null) |
|
| 124 | 124 | { |
| 125 | - if(!isset($this->options)) { |
|
| 125 | + if (!isset($this->options)) { |
|
| 126 | 126 | $this->options = $this->getDefaultOptions(); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | public function hasOption(string $name) : bool |
| 133 | 133 | { |
| 134 | - if(!isset($this->options)) { |
|
| 134 | + if (!isset($this->options)) { |
|
| 135 | 135 | $this->options = $this->getDefaultOptions(); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function getOptions() : array |
| 145 | 145 | { |
| 146 | - if(!isset($this->options)) { |
|
| 146 | + if (!isset($this->options)) { |
|
| 147 | 147 | $this->options = $this->getDefaultOptions(); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Creates and returns a new instance of the CSV builder which |
|
| 83 | - * can be used to build CSV from scratch. |
|
| 84 | - * |
|
| 85 | - * @return CSVHelper_Builder |
|
| 86 | - */ |
|
| 81 | + /** |
|
| 82 | + * Creates and returns a new instance of the CSV builder which |
|
| 83 | + * can be used to build CSV from scratch. |
|
| 84 | + * |
|
| 85 | + * @return CSVHelper_Builder |
|
| 86 | + */ |
|
| 87 | 87 | public static function createBuilder() : CSVHelper_Builder |
| 88 | 88 | { |
| 89 | 89 | return new CSVHelper_Builder(); |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Loads CSV data from a string. |
|
| 96 | - * |
|
| 97 | - * Note: Use the {@link hasErrors()} method to |
|
| 98 | - * check if the string could be parsed correctly |
|
| 99 | - * afterwards. |
|
| 100 | - * |
|
| 101 | - * @param string $string |
|
| 102 | - * @return $this |
|
| 103 | - */ |
|
| 94 | + /** |
|
| 95 | + * Loads CSV data from a string. |
|
| 96 | + * |
|
| 97 | + * Note: Use the {@link hasErrors()} method to |
|
| 98 | + * check if the string could be parsed correctly |
|
| 99 | + * afterwards. |
|
| 100 | + * |
|
| 101 | + * @param string $string |
|
| 102 | + * @return $this |
|
| 103 | + */ |
|
| 104 | 104 | public function loadString(string $string) : self |
| 105 | 105 | { |
| 106 | 106 | // remove any UTF byte order marks that may still be present in the string |
@@ -114,20 +114,20 @@ discard block |
||
| 114 | 114 | return $this; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Loads CSV data from a file. |
|
| 119 | - * |
|
| 120 | - * Note: Use the {@link hasErrors()} method to |
|
| 121 | - * check if the string could be parsed correctly |
|
| 122 | - * afterwards. |
|
| 123 | - * |
|
| 124 | - * @param string $file |
|
| 125 | - * @throws FileHelper_Exception |
|
| 126 | - * @return CSVHelper |
|
| 127 | - * |
|
| 128 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
| 129 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
| 130 | - */ |
|
| 117 | + /** |
|
| 118 | + * Loads CSV data from a file. |
|
| 119 | + * |
|
| 120 | + * Note: Use the {@link hasErrors()} method to |
|
| 121 | + * check if the string could be parsed correctly |
|
| 122 | + * afterwards. |
|
| 123 | + * |
|
| 124 | + * @param string $file |
|
| 125 | + * @throws FileHelper_Exception |
|
| 126 | + * @return CSVHelper |
|
| 127 | + * |
|
| 128 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
| 129 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
| 130 | + */ |
|
| 131 | 131 | public function loadFile(string $file) : self |
| 132 | 132 | { |
| 133 | 133 | $csv = FileHelper::readContents($file); |
@@ -188,19 +188,19 @@ discard block |
||
| 188 | 188 | return $this->headersPosition === $position; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Specifies where the headers are positioned in the |
|
| 193 | - * CSV, or turns them off entirely. Use the class constants |
|
| 194 | - * to ensure the value is correct. |
|
| 195 | - * |
|
| 196 | - * @param string $position |
|
| 197 | - * @throws CSVHelper_Exception |
|
| 198 | - * @return $this |
|
| 199 | - * |
|
| 200 | - * @see CSVHelper::HEADERS_LEFT |
|
| 201 | - * @see CSVHelper::HEADERS_TOP |
|
| 202 | - * @see CSVHelper::HEADERS_NONE |
|
| 203 | - */ |
|
| 191 | + /** |
|
| 192 | + * Specifies where the headers are positioned in the |
|
| 193 | + * CSV, or turns them off entirely. Use the class constants |
|
| 194 | + * to ensure the value is correct. |
|
| 195 | + * |
|
| 196 | + * @param string $position |
|
| 197 | + * @throws CSVHelper_Exception |
|
| 198 | + * @return $this |
|
| 199 | + * |
|
| 200 | + * @see CSVHelper::HEADERS_LEFT |
|
| 201 | + * @see CSVHelper::HEADERS_TOP |
|
| 202 | + * @see CSVHelper::HEADERS_NONE |
|
| 203 | + */ |
|
| 204 | 204 | public function setHeadersPosition(string $position) : self |
| 205 | 205 | { |
| 206 | 206 | $validPositions = array( |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | return $this; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * Resets all internal data, allowing to start entirely anew |
|
| 232 | - * with a new file, or to start building a new CSV file from |
|
| 233 | - * scratch. |
|
| 234 | - * |
|
| 235 | - * @return $this |
|
| 236 | - */ |
|
| 230 | + /** |
|
| 231 | + * Resets all internal data, allowing to start entirely anew |
|
| 232 | + * with a new file, or to start building a new CSV file from |
|
| 233 | + * scratch. |
|
| 234 | + * |
|
| 235 | + * @return $this |
|
| 236 | + */ |
|
| 237 | 237 | public function reset() : self |
| 238 | 238 | { |
| 239 | 239 | $this->data = array(); |
@@ -253,81 +253,81 @@ discard block |
||
| 253 | 253 | return $this->data; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Retrieves the row at the specified index. |
|
| 258 | - * If there is no data at the index, this will |
|
| 259 | - * return an array populated with empty strings |
|
| 260 | - * for all available columns. |
|
| 261 | - * |
|
| 262 | - * Tip: Use the {@link rowExists()} method to check |
|
| 263 | - * whether the specified row exists. |
|
| 264 | - * |
|
| 265 | - * @param integer $index |
|
| 266 | - * @return array<int,mixed> |
|
| 267 | - * @see rowExists() |
|
| 268 | - */ |
|
| 256 | + /** |
|
| 257 | + * Retrieves the row at the specified index. |
|
| 258 | + * If there is no data at the index, this will |
|
| 259 | + * return an array populated with empty strings |
|
| 260 | + * for all available columns. |
|
| 261 | + * |
|
| 262 | + * Tip: Use the {@link rowExists()} method to check |
|
| 263 | + * whether the specified row exists. |
|
| 264 | + * |
|
| 265 | + * @param integer $index |
|
| 266 | + * @return array<int,mixed> |
|
| 267 | + * @see rowExists() |
|
| 268 | + */ |
|
| 269 | 269 | public function getRow(int $index) : array |
| 270 | 270 | { |
| 271 | 271 | return $this->data[$index] ?? array_fill(0, $this->rowCount, ''); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * Checks whether the specified row exists in the data set. |
|
| 276 | - * @param integer $index |
|
| 277 | - * @return boolean |
|
| 278 | - */ |
|
| 274 | + /** |
|
| 275 | + * Checks whether the specified row exists in the data set. |
|
| 276 | + * @param integer $index |
|
| 277 | + * @return boolean |
|
| 278 | + */ |
|
| 279 | 279 | public function rowExists(int $index) : bool |
| 280 | 280 | { |
| 281 | 281 | return isset($this->data[$index]); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - /** |
|
| 285 | - * Counts the amount of rows in the parsed CSV, |
|
| 286 | - * excluding the headers if any, depending on |
|
| 287 | - * their position. |
|
| 288 | - * |
|
| 289 | - * @return integer |
|
| 290 | - */ |
|
| 284 | + /** |
|
| 285 | + * Counts the amount of rows in the parsed CSV, |
|
| 286 | + * excluding the headers if any, depending on |
|
| 287 | + * their position. |
|
| 288 | + * |
|
| 289 | + * @return integer |
|
| 290 | + */ |
|
| 291 | 291 | public function countRows() : int |
| 292 | 292 | { |
| 293 | 293 | return $this->rowCount; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * Counts the amount of rows in the parsed CSV, |
|
| 298 | - * excluding the headers if any, depending on |
|
| 299 | - * their position. |
|
| 300 | - * |
|
| 301 | - * @return integer |
|
| 302 | - */ |
|
| 296 | + /** |
|
| 297 | + * Counts the amount of rows in the parsed CSV, |
|
| 298 | + * excluding the headers if any, depending on |
|
| 299 | + * their position. |
|
| 300 | + * |
|
| 301 | + * @return integer |
|
| 302 | + */ |
|
| 303 | 303 | public function countColumns() : int |
| 304 | 304 | { |
| 305 | 305 | return $this->columnCount; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * Retrieves the headers, if any. Specify the position of the |
|
| 310 | - * headers first to ensure this works correctly. |
|
| 311 | - * |
|
| 312 | - * @return string[] Indexed array with header names. |
|
| 313 | - */ |
|
| 308 | + /** |
|
| 309 | + * Retrieves the headers, if any. Specify the position of the |
|
| 310 | + * headers first to ensure this works correctly. |
|
| 311 | + * |
|
| 312 | + * @return string[] Indexed array with header names. |
|
| 313 | + */ |
|
| 314 | 314 | public function getHeaders() : array |
| 315 | 315 | { |
| 316 | 316 | return $this->headers; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Retrieves the column at the specified index. If there |
|
| 321 | - * is no column at the index, this returns an array |
|
| 322 | - * populated with empty strings. |
|
| 323 | - * |
|
| 324 | - * Tip: Use the {@link columnExists()} method to check |
|
| 325 | - * whether a column exists. |
|
| 326 | - * |
|
| 327 | - * @param integer $index |
|
| 328 | - * @return string[] |
|
| 329 | - * @see columnExists() |
|
| 330 | - */ |
|
| 319 | + /** |
|
| 320 | + * Retrieves the column at the specified index. If there |
|
| 321 | + * is no column at the index, this returns an array |
|
| 322 | + * populated with empty strings. |
|
| 323 | + * |
|
| 324 | + * Tip: Use the {@link columnExists()} method to check |
|
| 325 | + * whether a column exists. |
|
| 326 | + * |
|
| 327 | + * @param integer $index |
|
| 328 | + * @return string[] |
|
| 329 | + * @see columnExists() |
|
| 330 | + */ |
|
| 331 | 331 | public function getColumn(int $index) : array |
| 332 | 332 | { |
| 333 | 333 | $data = array(); |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | return $data; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - /** |
|
| 346 | - * Checks whether the specified column exists in the data set. |
|
| 347 | - * @param integer $index |
|
| 348 | - * @return boolean |
|
| 349 | - */ |
|
| 345 | + /** |
|
| 346 | + * Checks whether the specified column exists in the data set. |
|
| 347 | + * @param integer $index |
|
| 348 | + * @return boolean |
|
| 349 | + */ |
|
| 350 | 350 | public function columnExists(int $index) : bool |
| 351 | 351 | { |
| 352 | 352 | return $index < $this->columnCount; |
@@ -406,22 +406,22 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - /** |
|
| 410 | - * Checks whether any errors have been encountered |
|
| 411 | - * while parsing the CSV. |
|
| 412 | - * |
|
| 413 | - * @return boolean |
|
| 414 | - * @see getErrorMessages() |
|
| 415 | - */ |
|
| 409 | + /** |
|
| 410 | + * Checks whether any errors have been encountered |
|
| 411 | + * while parsing the CSV. |
|
| 412 | + * |
|
| 413 | + * @return boolean |
|
| 414 | + * @see getErrorMessages() |
|
| 415 | + */ |
|
| 416 | 416 | public function hasErrors() : bool |
| 417 | 417 | { |
| 418 | 418 | return !empty($this->errors); |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - /** |
|
| 422 | - * Retrieves all error messages. |
|
| 423 | - * @return string[] |
|
| 424 | - */ |
|
| 421 | + /** |
|
| 422 | + * Retrieves all error messages. |
|
| 423 | + * @return string[] |
|
| 424 | + */ |
|
| 425 | 425 | public function getErrorMessages() : array |
| 426 | 426 | { |
| 427 | 427 | return $this->errors; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | self::HEADERS_TOP |
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | - if(!in_array($position, $validPositions)) { |
|
| 212 | + if (!in_array($position, $validPositions)) { |
|
| 213 | 213 | throw new CSVHelper_Exception( |
| 214 | 214 | 'Invalid headers position', |
| 215 | 215 | sprintf( |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | { |
| 333 | 333 | $data = array(); |
| 334 | 334 | |
| 335 | - for($i=0; $i < $this->rowCount; $i++) |
|
| 335 | + for ($i = 0; $i < $this->rowCount; $i++) |
|
| 336 | 336 | { |
| 337 | 337 | $value = $this->data[$i][$index] ?? ''; |
| 338 | 338 | |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | { |
| 357 | 357 | $this->reset(); |
| 358 | 358 | |
| 359 | - if(empty(trim($this->csv))) { |
|
| 359 | + if (empty(trim($this->csv))) { |
|
| 360 | 360 | $this->addError('Tried to parse an empty CSV string.'); |
| 361 | 361 | return; |
| 362 | 362 | } |
@@ -368,14 +368,14 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | $parser = self::createParser(); |
| 370 | 370 | |
| 371 | - if(!$parser->parse($this->csv)) { |
|
| 371 | + if (!$parser->parse($this->csv)) { |
|
| 372 | 372 | $this->addError('The CSV string could not be parsed.'); |
| 373 | 373 | return; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | $result = $parser->data; |
| 377 | 377 | |
| 378 | - switch($this->headersPosition) |
|
| 378 | + switch ($this->headersPosition) |
|
| 379 | 379 | { |
| 380 | 380 | case self::HEADERS_TOP: |
| 381 | 381 | $this->headers = array_shift($result); |
@@ -398,9 +398,9 @@ discard block |
||
| 398 | 398 | $this->data = $result; |
| 399 | 399 | $this->rowCount = count($this->data); |
| 400 | 400 | |
| 401 | - for($i=0; $i < $this->rowCount; $i++) { |
|
| 401 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
| 402 | 402 | $amount = count($this->data[$i]); |
| 403 | - if($amount > $this->columnCount) { |
|
| 403 | + if ($amount > $this->columnCount) { |
|
| 404 | 404 | $this->columnCount = $amount; |
| 405 | 405 | } |
| 406 | 406 | } |
@@ -443,8 +443,8 @@ discard block |
||
| 443 | 443 | ',,' => ',' |
| 444 | 444 | ); |
| 445 | 445 | |
| 446 | - foreach($search as $char => $separator) { |
|
| 447 | - if(strpos($this->csv, $char) !== false) { |
|
| 446 | + foreach ($search as $char => $separator) { |
|
| 447 | + if (strpos($this->csv, $char) !== false) { |
|
| 448 | 448 | return $separator; |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -458,11 +458,11 @@ discard block |
||
| 458 | 458 | * @param string $delimiter |
| 459 | 459 | * @return Csv |
| 460 | 460 | */ |
| 461 | - public static function createParser(string $delimiter=self::DELIMITER_AUTO) : Csv |
|
| 461 | + public static function createParser(string $delimiter = self::DELIMITER_AUTO) : Csv |
|
| 462 | 462 | { |
| 463 | 463 | $csv = new Csv(); |
| 464 | 464 | |
| 465 | - if($delimiter !== self::DELIMITER_AUTO) { |
|
| 465 | + if ($delimiter !== self::DELIMITER_AUTO) { |
|
| 466 | 466 | $csv->delimiter = $delimiter; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | |
| 494 | 494 | $result = $parser->auto($path); |
| 495 | 495 | |
| 496 | - if(is_string($result)) { |
|
| 496 | + if (is_string($result)) { |
|
| 497 | 497 | return $parser->data; |
| 498 | 498 | } |
| 499 | 499 | |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $parser = self::createParser(); |
| 527 | 527 | $result = $parser->parse($string); |
| 528 | 528 | |
| 529 | - if($result === true) { |
|
| 529 | + if ($result === true) { |
|
| 530 | 530 | return $parser->data; |
| 531 | 531 | } |
| 532 | 532 | |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Whether to verify the host's SSL certificate, in |
|
| 48 | - * case of a https connection. |
|
| 49 | - * |
|
| 50 | - * @param bool $verifySSL |
|
| 51 | - * @return URIConnectionTester |
|
| 52 | - */ |
|
| 46 | + /** |
|
| 47 | + * Whether to verify the host's SSL certificate, in |
|
| 48 | + * case of a https connection. |
|
| 49 | + * |
|
| 50 | + * @param bool $verifySSL |
|
| 51 | + * @return URIConnectionTester |
|
| 52 | + */ |
|
| 53 | 53 | public function setVerifySSL(bool $verifySSL=true) : URIConnectionTester |
| 54 | 54 | { |
| 55 | 55 | $this->setOption('verify-ssl', $verifySSL); |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | return $this->getIntOption('timeout'); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @param resource|CurlHandle $ch |
|
| 88 | - */ |
|
| 86 | + /** |
|
| 87 | + * @param resource|CurlHandle $ch |
|
| 88 | + */ |
|
| 89 | 89 | private function configureOptions($ch) : void |
| 90 | 90 | { |
| 91 | 91 | if($this->isVerboseModeEnabled()) |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param bool $verifySSL |
| 51 | 51 | * @return URIConnectionTester |
| 52 | 52 | */ |
| 53 | - public function setVerifySSL(bool $verifySSL=true) : URIConnectionTester |
|
| 53 | + public function setVerifySSL(bool $verifySSL = true) : URIConnectionTester |
|
| 54 | 54 | { |
| 55 | 55 | $this->setOption('verify-ssl', $verifySSL); |
| 56 | 56 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | return $this->getBoolOption('verify-ssl'); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function setVerboseMode(bool $enabled=true) : URIConnectionTester |
|
| 64 | + public function setVerboseMode(bool $enabled = true) : URIConnectionTester |
|
| 65 | 65 | { |
| 66 | 66 | $this->setOption('curl-verbose', $enabled); |
| 67 | 67 | return $this; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | private function configureOptions($ch) : void |
| 90 | 90 | { |
| 91 | - if($this->isVerboseModeEnabled()) |
|
| 91 | + if ($this->isVerboseModeEnabled()) |
|
| 92 | 92 | { |
| 93 | 93 | curl_setopt($ch, CURLOPT_VERBOSE, true); |
| 94 | 94 | } |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->getTimeout()); |
| 99 | 99 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 100 | 100 | |
| 101 | - if(!$this->isVerifySSLEnabled()) |
|
| 101 | + if (!$this->isVerifySSLEnabled()) |
|
| 102 | 102 | { |
| 103 | 103 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 104 | 104 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if($this->url->hasUsername()) |
|
| 107 | + if ($this->url->hasUsername()) |
|
| 108 | 108 | { |
| 109 | 109 | curl_setopt($ch, CURLOPT_USERNAME, $this->url->getUsername()); |
| 110 | 110 | curl_setopt($ch, CURLOPT_PASSWORD, $this->url->getPassword()); |
@@ -46,19 +46,19 @@ discard block |
||
| 46 | 46 | protected int $contentLength = 0; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * @var array<string,string> |
|
| 50 | - */ |
|
| 49 | + * @var array<string,string> |
|
| 50 | + */ |
|
| 51 | 51 | protected $headers = array(); |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var resource|NULL |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * @var resource|NULL |
|
| 55 | + */ |
|
| 56 | 56 | protected $logfilePointer; |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Creates a new request helper to send POST data to the specified destination URL. |
|
| 60 | - * @param string $destinationURL |
|
| 61 | - */ |
|
| 58 | + /** |
|
| 59 | + * Creates a new request helper to send POST data to the specified destination URL. |
|
| 60 | + * @param string $destinationURL |
|
| 61 | + */ |
|
| 62 | 62 | public function __construct(string $destinationURL) |
| 63 | 63 | { |
| 64 | 64 | $this->destination = $destinationURL; |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | return $this->eol; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Sets the timeout for the request, in seconds. If the request |
|
| 86 | - * takes longer, it will be cancelled and an exception triggered. |
|
| 87 | - * |
|
| 88 | - * @param int $seconds |
|
| 89 | - * @return RequestHelper |
|
| 90 | - */ |
|
| 84 | + /** |
|
| 85 | + * Sets the timeout for the request, in seconds. If the request |
|
| 86 | + * takes longer, it will be cancelled and an exception triggered. |
|
| 87 | + * |
|
| 88 | + * @param int $seconds |
|
| 89 | + * @return RequestHelper |
|
| 90 | + */ |
|
| 91 | 91 | public function setTimeout(int $seconds) : RequestHelper |
| 92 | 92 | { |
| 93 | 93 | $this->timeout = $seconds; |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | return $this->timeout; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Enables verbose logging of the CURL request, which |
|
| 105 | - * is then redirected to the target file. |
|
| 106 | - * |
|
| 107 | - * @param string $targetFile |
|
| 108 | - * @return RequestHelper |
|
| 109 | - */ |
|
| 103 | + /** |
|
| 104 | + * Enables verbose logging of the CURL request, which |
|
| 105 | + * is then redirected to the target file. |
|
| 106 | + * |
|
| 107 | + * @param string $targetFile |
|
| 108 | + * @return RequestHelper |
|
| 109 | + */ |
|
| 110 | 110 | public function enableLogging(string $targetFile) : RequestHelper |
| 111 | 111 | { |
| 112 | 112 | $this->logfile = $targetFile; |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | return $this; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Adds a file to be sent with the request. |
|
| 119 | - * |
|
| 120 | - * @param string $varName The variable name to send the file in |
|
| 121 | - * @param string $fileName The name of the file as it should be received at the destination |
|
| 122 | - * @param string $content The raw content of the file |
|
| 123 | - * @param string $contentType The content type, use the constants to specify this |
|
| 124 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
| 125 | - */ |
|
| 117 | + /** |
|
| 118 | + * Adds a file to be sent with the request. |
|
| 119 | + * |
|
| 120 | + * @param string $varName The variable name to send the file in |
|
| 121 | + * @param string $fileName The name of the file as it should be received at the destination |
|
| 122 | + * @param string $content The raw content of the file |
|
| 123 | + * @param string $contentType The content type, use the constants to specify this |
|
| 124 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
| 125 | + */ |
|
| 126 | 126 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper |
| 127 | 127 | { |
| 128 | 128 | $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding); |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | return $this; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Sets an HTTP header to include in the request. |
|
| 165 | - * |
|
| 166 | - * @param string $name |
|
| 167 | - * @param string $value |
|
| 168 | - * @return RequestHelper |
|
| 169 | - */ |
|
| 163 | + /** |
|
| 164 | + * Sets an HTTP header to include in the request. |
|
| 165 | + * |
|
| 166 | + * @param string $name |
|
| 167 | + * @param string $value |
|
| 168 | + * @return RequestHelper |
|
| 169 | + */ |
|
| 170 | 170 | public function setHeader(string $name, string $value) : RequestHelper |
| 171 | 171 | { |
| 172 | 172 | $this->headers[$name] = $value; |
@@ -174,31 +174,31 @@ discard block |
||
| 174 | 174 | return $this; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Disables SSL certificate checking. |
|
| 179 | - * |
|
| 180 | - * @return RequestHelper |
|
| 181 | - */ |
|
| 177 | + /** |
|
| 178 | + * Disables SSL certificate checking. |
|
| 179 | + * |
|
| 180 | + * @return RequestHelper |
|
| 181 | + */ |
|
| 182 | 182 | public function disableSSLChecks() : RequestHelper |
| 183 | 183 | { |
| 184 | 184 | $this->verifySSL = false; |
| 185 | 185 | return $this; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Sends the POST request to the destination, and returns |
|
| 190 | - * the response text. |
|
| 191 | - * |
|
| 192 | - * The response object is stored internally, so after calling |
|
| 193 | - * this method it may be retrieved at any moment using the |
|
| 194 | - * {@link getResponse()} method. |
|
| 195 | - * |
|
| 196 | - * @return string |
|
| 197 | - * @see RequestHelper::getResponse() |
|
| 198 | - * @throws RequestHelper_Exception |
|
| 199 | - * |
|
| 200 | - * @see RequestHelper::ERROR_REQUEST_FAILED |
|
| 201 | - */ |
|
| 188 | + /** |
|
| 189 | + * Sends the POST request to the destination, and returns |
|
| 190 | + * the response text. |
|
| 191 | + * |
|
| 192 | + * The response object is stored internally, so after calling |
|
| 193 | + * this method it may be retrieved at any moment using the |
|
| 194 | + * {@link getResponse()} method. |
|
| 195 | + * |
|
| 196 | + * @return string |
|
| 197 | + * @see RequestHelper::getResponse() |
|
| 198 | + * @throws RequestHelper_Exception |
|
| 199 | + * |
|
| 200 | + * @see RequestHelper::ERROR_REQUEST_FAILED |
|
| 201 | + */ |
|
| 202 | 202 | public function send() : string |
| 203 | 203 | { |
| 204 | 204 | $info = parseURL($this->destination); |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | return $this->response->getResponseBody(); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Retrieves the request's body content. This is an alias |
|
| 243 | - * for {@see RequestHelper::getMimeBody()}. |
|
| 244 | - * |
|
| 245 | - * @return string |
|
| 246 | - * @see RequestHelper::getMimeBody() |
|
| 247 | - */ |
|
| 241 | + /** |
|
| 242 | + * Retrieves the request's body content. This is an alias |
|
| 243 | + * for {@see RequestHelper::getMimeBody()}. |
|
| 244 | + * |
|
| 245 | + * @return string |
|
| 246 | + * @see RequestHelper::getMimeBody() |
|
| 247 | + */ |
|
| 248 | 248 | public function getBody() : string |
| 249 | 249 | { |
| 250 | 250 | return $this->getMimeBody(); |
@@ -276,14 +276,14 @@ discard block |
||
| 276 | 276 | ); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Creates a new CURL resource configured according to the |
|
| 281 | - * request's settings. |
|
| 282 | - * |
|
| 283 | - * @param URLInfo $url |
|
| 284 | - * @throws RequestHelper_Exception |
|
| 285 | - * @return resource |
|
| 286 | - */ |
|
| 279 | + /** |
|
| 280 | + * Creates a new CURL resource configured according to the |
|
| 281 | + * request's settings. |
|
| 282 | + * |
|
| 283 | + * @param URLInfo $url |
|
| 284 | + * @throws RequestHelper_Exception |
|
| 285 | + * @return resource |
|
| 286 | + */ |
|
| 287 | 287 | protected function configureCURL(URLInfo $url) |
| 288 | 288 | { |
| 289 | 289 | $ch = self::createCURL(); |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | return true; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - /** |
|
| 357 | - * Compiles the associative headers array into |
|
| 358 | - * the format understood by CURL, namely an indexed |
|
| 359 | - * array with one header string per entry. |
|
| 360 | - * |
|
| 361 | - * @return string[] |
|
| 362 | - */ |
|
| 356 | + /** |
|
| 357 | + * Compiles the associative headers array into |
|
| 358 | + * the format understood by CURL, namely an indexed |
|
| 359 | + * array with one header string per entry. |
|
| 360 | + * |
|
| 361 | + * @return string[] |
|
| 362 | + */ |
|
| 363 | 363 | protected function renderHeaders() : array |
| 364 | 364 | { |
| 365 | 365 | $result = array(); |
@@ -373,12 +373,12 @@ discard block |
||
| 373 | 373 | return $result; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Retrieves the raw response header, in the form of an indexed |
|
| 378 | - * array containing all response header lines. |
|
| 379 | - * |
|
| 380 | - * @return string[] |
|
| 381 | - */ |
|
| 376 | + /** |
|
| 377 | + * Retrieves the raw response header, in the form of an indexed |
|
| 378 | + * array containing all response header lines. |
|
| 379 | + * |
|
| 380 | + * @return string[] |
|
| 381 | + */ |
|
| 382 | 382 | public function getResponseHeader() : array |
| 383 | 383 | { |
| 384 | 384 | $response = $this->getResponse(); |
@@ -390,33 +390,33 @@ discard block |
||
| 390 | 390 | return array(); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - /** |
|
| 394 | - * After calling the {@link send()} method, this may be used to |
|
| 395 | - * retrieve the response text from the POST request. |
|
| 396 | - * |
|
| 397 | - * @return RequestHelper_Response|NULL |
|
| 398 | - */ |
|
| 393 | + /** |
|
| 394 | + * After calling the {@link send()} method, this may be used to |
|
| 395 | + * retrieve the response text from the POST request. |
|
| 396 | + * |
|
| 397 | + * @return RequestHelper_Response|NULL |
|
| 398 | + */ |
|
| 399 | 399 | public function getResponse() : ?RequestHelper_Response |
| 400 | 400 | { |
| 401 | 401 | return $this->response; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - /** |
|
| 405 | - * Retrieves all headers set until now. |
|
| 406 | - * |
|
| 407 | - * @return array<string,string> |
|
| 408 | - */ |
|
| 404 | + /** |
|
| 405 | + * Retrieves all headers set until now. |
|
| 406 | + * |
|
| 407 | + * @return array<string,string> |
|
| 408 | + */ |
|
| 409 | 409 | public function getHeaders() : array |
| 410 | 410 | { |
| 411 | 411 | return $this->headers; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - /** |
|
| 415 | - * Retrieves the value of a header by its name. |
|
| 416 | - * |
|
| 417 | - * @param string $name |
|
| 418 | - * @return string The header value, or an empty string if not set. |
|
| 419 | - */ |
|
| 414 | + /** |
|
| 415 | + * Retrieves the value of a header by its name. |
|
| 416 | + * |
|
| 417 | + * @param string $name |
|
| 418 | + * @return string The header value, or an empty string if not set. |
|
| 419 | + */ |
|
| 420 | 420 | public function getHeader(string $name) : string |
| 421 | 421 | { |
| 422 | 422 | return $this->headers[$name] ?? ''; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $output = curl_exec($ch); |
| 209 | 209 | |
| 210 | - if(isset($this->logfilePointer)) |
|
| 210 | + if (isset($this->logfilePointer)) |
|
| 211 | 211 | { |
| 212 | 212 | fclose($this->logfilePointer); |
| 213 | 213 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | // CURL will complain about an empty response when the |
| 220 | 220 | // server sends a 100-continue code. That should not be |
| 221 | 221 | // regarded as an error. |
| 222 | - if($output === false && $this->response->getCode() !== 100) |
|
| 222 | + if ($output === false && $this->response->getCode() !== 100) |
|
| 223 | 223 | { |
| 224 | 224 | $curlCode = curl_errno($ch); |
| 225 | 225 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | { |
| 262 | 262 | $ch = curl_init(); |
| 263 | 263 | |
| 264 | - if($ch instanceof CurlHandle || is_resource($ch)) |
|
| 264 | + if ($ch instanceof CurlHandle || is_resource($ch)) |
|
| 265 | 265 | { |
| 266 | 266 | return $ch; |
| 267 | 267 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $ch = self::createCURL(); |
| 290 | 290 | |
| 291 | 291 | $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength()); |
| 292 | - $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary); |
|
| 292 | + $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary); |
|
| 293 | 293 | |
| 294 | 294 | curl_setopt($ch, CURLOPT_POST, true); |
| 295 | 295 | curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth()); |
@@ -302,18 +302,18 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $loggingEnabled = $this->configureLogging($ch); |
| 304 | 304 | |
| 305 | - if(!$loggingEnabled) |
|
| 305 | + if (!$loggingEnabled) |
|
| 306 | 306 | { |
| 307 | 307 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if($this->verifySSL) |
|
| 310 | + if ($this->verifySSL) |
|
| 311 | 311 | { |
| 312 | 312 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 313 | 313 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if($url->hasUsername()) |
|
| 316 | + if ($url->hasUsername()) |
|
| 317 | 317 | { |
| 318 | 318 | curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername()); |
| 319 | 319 | curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword()); |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | protected function configureLogging($ch) : bool |
| 331 | 331 | { |
| 332 | - if(empty($this->logfile)) |
|
| 332 | + if (empty($this->logfile)) |
|
| 333 | 333 | { |
| 334 | 334 | return false; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | $res = fopen($this->logfile, 'wb+'); |
| 338 | 338 | |
| 339 | - if($res === false) |
|
| 339 | + if ($res === false) |
|
| 340 | 340 | { |
| 341 | 341 | throw new RequestHelper_Exception( |
| 342 | 342 | 'Cannot open logfile for writing.', |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | $this->setHeader('Expect', ''); |
| 368 | 368 | |
| 369 | - foreach($this->headers as $name => $value) { |
|
| 369 | + foreach ($this->headers as $name => $value) { |
|
| 370 | 370 | $result[] = $name.': '.$value; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | { |
| 384 | 384 | $response = $this->getResponse(); |
| 385 | 385 | |
| 386 | - if($response !== null) { |
|
| 386 | + if ($response !== null) { |
|
| 387 | 387 | return $response->getHeaders(); |
| 388 | 388 | } |
| 389 | 389 | |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | declare(strict_types=1); |
| 8 | 8 | |
| 9 | -if(!class_exists('CurlHandle')) |
|
| 9 | +if (!class_exists('CurlHandle')) |
|
| 10 | 10 | { |
| 11 | 11 | /** |
| 12 | 12 | * Shim to support PHPStan analysis on PHP7, while |