@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | class OperationResult_Collection extends OperationResult |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * @var OperationResult[] |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var OperationResult[] |
|
| 31 | + */ |
|
| 32 | 32 | protected $results = array(); |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | return $this; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * @return OperationResult[] |
|
| 128 | - */ |
|
| 126 | + /** |
|
| 127 | + * @return OperationResult[] |
|
| 128 | + */ |
|
| 129 | 129 | public function getResults() : array |
| 130 | 130 | { |
| 131 | 131 | return $this->results; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param int $code |
| 37 | 37 | * @return $this |
| 38 | 38 | */ |
| 39 | - public function makeError(string $message, int $code=0) : OperationResult |
|
| 39 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
| 40 | 40 | { |
| 41 | 41 | return $this->add('makeError', $message, $code); |
| 42 | 42 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param int $code |
| 47 | 47 | * @return $this |
| 48 | 48 | */ |
| 49 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
| 49 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
| 50 | 50 | { |
| 51 | 51 | return $this->add('makeSuccess', $message, $code); |
| 52 | 52 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param int $code |
| 57 | 57 | * @return $this |
| 58 | 58 | */ |
| 59 | - public function makeWarning(string $message, int $code=0) : OperationResult |
|
| 59 | + public function makeWarning(string $message, int $code = 0) : OperationResult |
|
| 60 | 60 | { |
| 61 | 61 | return $this->add('makeWarning', $message, $code); |
| 62 | 62 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param int $code |
| 67 | 67 | * @return $this |
| 68 | 68 | */ |
| 69 | - public function makeNotice(string $message, int $code=0) : OperationResult |
|
| 69 | + public function makeNotice(string $message, int $code = 0) : OperationResult |
|
| 70 | 70 | { |
| 71 | 71 | return $this->add('makeNotice', $message, $code); |
| 72 | 72 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param int $code |
| 78 | 78 | * @return $this |
| 79 | 79 | */ |
| 80 | - protected function add(string $method, string $message, int $code=0) : OperationResult |
|
| 80 | + protected function add(string $method, string $message, int $code = 0) : OperationResult |
|
| 81 | 81 | { |
| 82 | 82 | $result = new OperationResult($this->subject); |
| 83 | 83 | $result->$method($message, $code); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function addResult(OperationResult $result) : OperationResult_Collection |
| 97 | 97 | { |
| 98 | - if($result instanceof OperationResult_Collection) |
|
| 98 | + if ($result instanceof OperationResult_Collection) |
|
| 99 | 99 | { |
| 100 | 100 | return $this->importCollection($result); |
| 101 | 101 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $results = $collection->getResults(); |
| 117 | 117 | |
| 118 | - foreach($results as $result) |
|
| 118 | + foreach ($results as $result) |
|
| 119 | 119 | { |
| 120 | 120 | $this->addResult($result); |
| 121 | 121 | } |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | public function isValid() : bool |
| 135 | 135 | { |
| 136 | - foreach($this->results as $result) |
|
| 136 | + foreach ($this->results as $result) |
|
| 137 | 137 | { |
| 138 | - if(!$result->isValid()) |
|
| 138 | + if (!$result->isValid()) |
|
| 139 | 139 | { |
| 140 | 140 | return false; |
| 141 | 141 | } |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | public function hasCode() : bool |
| 148 | 148 | { |
| 149 | - foreach($this->results as $result) |
|
| 149 | + foreach ($this->results as $result) |
|
| 150 | 150 | { |
| 151 | - if($result->hasCode()) |
|
| 151 | + if ($result->hasCode()) |
|
| 152 | 152 | { |
| 153 | 153 | return true; |
| 154 | 154 | } |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | public function getCode() : int |
| 161 | 161 | { |
| 162 | - foreach($this->results as $result) |
|
| 162 | + foreach ($this->results as $result) |
|
| 163 | 163 | { |
| 164 | - if($result->hasCode()) |
|
| 164 | + if ($result->hasCode()) |
|
| 165 | 165 | { |
| 166 | 166 | return $result->getCode(); |
| 167 | 167 | } |
@@ -170,13 +170,13 @@ discard block |
||
| 170 | 170 | return 0; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function getMessage(string $type='') : string |
|
| 173 | + public function getMessage(string $type = '') : string |
|
| 174 | 174 | { |
| 175 | - foreach($this->results as $result) |
|
| 175 | + foreach ($this->results as $result) |
|
| 176 | 176 | { |
| 177 | 177 | $msg = $result->getMessage($type); |
| 178 | 178 | |
| 179 | - if(!empty($msg)) |
|
| 179 | + if (!empty($msg)) |
|
| 180 | 180 | { |
| 181 | 181 | return $msg; |
| 182 | 182 | } |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | public function containsCode(int $code) : bool |
| 189 | 189 | { |
| 190 | - foreach($this->results as $result) |
|
| 190 | + foreach ($this->results as $result) |
|
| 191 | 191 | { |
| 192 | - if($result->getCode() === $code) |
|
| 192 | + if ($result->getCode() === $code) |
|
| 193 | 193 | { |
| 194 | 194 | return true; |
| 195 | 195 | } |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $amount = 0; |
| 224 | 224 | |
| 225 | - foreach($this->results as $result) |
|
| 225 | + foreach ($this->results as $result) |
|
| 226 | 226 | { |
| 227 | - if($result->isType($type)) |
|
| 227 | + if ($result->isType($type)) |
|
| 228 | 228 | { |
| 229 | 229 | $amount++; |
| 230 | 230 | } |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | { |
| 263 | 263 | $results = array(); |
| 264 | 264 | |
| 265 | - foreach($this->results as $result) |
|
| 265 | + foreach ($this->results as $result) |
|
| 266 | 266 | { |
| 267 | - if($result->isType($type)) |
|
| 267 | + if ($result->isType($type)) |
|
| 268 | 268 | { |
| 269 | 269 | $results[] = $result; |
| 270 | 270 | } |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | public function isType(string $type) : bool |
| 277 | 277 | { |
| 278 | - foreach($this->results as $result) |
|
| 278 | + foreach ($this->results as $result) |
|
| 279 | 279 | { |
| 280 | - if($result->isType($type)) |
|
| 280 | + if ($result->isType($type)) |
|
| 281 | 281 | { |
| 282 | 282 | return true; |
| 283 | 283 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | $lines[] = 'Collection #'.$this->getID(); |
| 294 | 294 | $lines[] = 'Subject: '.get_class($this->subject); |
| 295 | 295 | |
| 296 | - foreach($this->results as $result) |
|
| 296 | + foreach ($this->results as $result) |
|
| 297 | 297 | { |
| 298 | 298 | $lines[] = ' - '.$result->getType().' #'.$result->getCode().' "'.$result->getMessage($result->getType()).'"'; |
| 299 | 299 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $message Should not contain a date, just the system specific info. |
| 145 | 145 | * @return $this |
| 146 | 146 | */ |
| 147 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
| 147 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
| 148 | 148 | { |
| 149 | 149 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
| 150 | 150 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param string $message Should be as detailed as possible. |
| 156 | 156 | * @return $this |
| 157 | 157 | */ |
| 158 | - public function makeError(string $message, int $code=0) : OperationResult |
|
| 158 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
| 159 | 159 | { |
| 160 | 160 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
| 161 | 161 | } |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | return $this->code; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - public function getMessage(string $type='') : string |
|
| 255 | + public function getMessage(string $type = '') : string |
|
| 256 | 256 | { |
| 257 | - if(!empty($type)) |
|
| 257 | + if (!empty($type)) |
|
| 258 | 258 | { |
| 259 | - if($this->type === $type) |
|
| 259 | + if ($this->type === $type) |
|
| 260 | 260 | { |
| 261 | 261 | return $this->message; |
| 262 | 262 | } |
@@ -280,11 +280,11 @@ discard block |
||
| 280 | 280 | * |
| 281 | 281 | * @throws ConvertHelper_Exception |
| 282 | 282 | */ |
| 283 | - public function makeException(Throwable $e, int $code=0, bool $withDeveloperInfo=false) : OperationResult |
|
| 283 | + public function makeException(Throwable $e, int $code = 0, bool $withDeveloperInfo = false) : OperationResult |
|
| 284 | 284 | { |
| 285 | 285 | $info = parseThrowable($e); |
| 286 | 286 | |
| 287 | - if($code === 0) |
|
| 287 | + if ($code === 0) |
|
| 288 | 288 | { |
| 289 | 289 | $code = $info->getCode(); |
| 290 | 290 | } |
@@ -34,46 +34,46 @@ discard block |
||
| 34 | 34 | public const TYPE_ERROR = 'error'; |
| 35 | 35 | public const TYPE_SUCCESS = 'success'; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | 40 | protected $message = ''; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var bool |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var bool |
|
| 44 | + */ |
|
| 45 | 45 | protected $valid = true; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var object |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var object |
|
| 49 | + */ |
|
| 50 | 50 | protected $subject; |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var integer |
|
| 54 | - */ |
|
| 52 | + /** |
|
| 53 | + * @var integer |
|
| 54 | + */ |
|
| 55 | 55 | protected $code = 0; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 57 | + /** |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | 60 | protected $type = ''; |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var integer |
|
| 64 | - */ |
|
| 62 | + /** |
|
| 63 | + * @var integer |
|
| 64 | + */ |
|
| 65 | 65 | private static $counter = 0; |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @var int |
|
| 69 | - */ |
|
| 67 | + /** |
|
| 68 | + * @var int |
|
| 69 | + */ |
|
| 70 | 70 | private $id; |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * The subject being validated. |
|
| 74 | - * |
|
| 75 | - * @param object $subject |
|
| 76 | - */ |
|
| 72 | + /** |
|
| 73 | + * The subject being validated. |
|
| 74 | + * |
|
| 75 | + * @param object $subject |
|
| 76 | + */ |
|
| 77 | 77 | public function __construct(object $subject) |
| 78 | 78 | { |
| 79 | 79 | $this->subject = $subject; |
@@ -83,21 +83,21 @@ discard block |
||
| 83 | 83 | $this->id = self::$counter; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Retrieves the ID of the result, which is unique within a request. |
|
| 88 | - * |
|
| 89 | - * @return int |
|
| 90 | - */ |
|
| 86 | + /** |
|
| 87 | + * Retrieves the ID of the result, which is unique within a request. |
|
| 88 | + * |
|
| 89 | + * @return int |
|
| 90 | + */ |
|
| 91 | 91 | public function getID() : int |
| 92 | 92 | { |
| 93 | 93 | return $this->id; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Whether the validation was successful. |
|
| 98 | - * |
|
| 99 | - * @return bool |
|
| 100 | - */ |
|
| 96 | + /** |
|
| 97 | + * Whether the validation was successful. |
|
| 98 | + * |
|
| 99 | + * @return bool |
|
| 100 | + */ |
|
| 101 | 101 | public function isValid() : bool |
| 102 | 102 | { |
| 103 | 103 | return $this->valid; |
@@ -128,33 +128,33 @@ discard block |
||
| 128 | 128 | return $this->type === $type; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Retrieves the subject that was validated. |
|
| 133 | - * |
|
| 134 | - * @return object |
|
| 135 | - */ |
|
| 131 | + /** |
|
| 132 | + * Retrieves the subject that was validated. |
|
| 133 | + * |
|
| 134 | + * @return object |
|
| 135 | + */ |
|
| 136 | 136 | public function getSubject() : object |
| 137 | 137 | { |
| 138 | 138 | return $this->subject; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Makes the result a success, with the specified message. |
|
| 143 | - * |
|
| 144 | - * @param string $message Should not contain a date, just the system specific info. |
|
| 145 | - * @return $this |
|
| 146 | - */ |
|
| 141 | + /** |
|
| 142 | + * Makes the result a success, with the specified message. |
|
| 143 | + * |
|
| 144 | + * @param string $message Should not contain a date, just the system specific info. |
|
| 145 | + * @return $this |
|
| 146 | + */ |
|
| 147 | 147 | public function makeSuccess(string $message, int $code=0) : OperationResult |
| 148 | 148 | { |
| 149 | 149 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Sets the result as an error. |
|
| 154 | - * |
|
| 155 | - * @param string $message Should be as detailed as possible. |
|
| 156 | - * @return $this |
|
| 157 | - */ |
|
| 152 | + /** |
|
| 153 | + * Sets the result as an error. |
|
| 154 | + * |
|
| 155 | + * @param string $message Should be as detailed as possible. |
|
| 156 | + * @return $this |
|
| 157 | + */ |
|
| 158 | 158 | public function makeError(string $message, int $code=0) : OperationResult |
| 159 | 159 | { |
| 160 | 160 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
@@ -202,21 +202,21 @@ discard block |
||
| 202 | 202 | return $this->type; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Retrieves the error message, if an error occurred. |
|
| 207 | - * |
|
| 208 | - * @return string The error message, or an empty string if no error occurred. |
|
| 209 | - */ |
|
| 205 | + /** |
|
| 206 | + * Retrieves the error message, if an error occurred. |
|
| 207 | + * |
|
| 208 | + * @return string The error message, or an empty string if no error occurred. |
|
| 209 | + */ |
|
| 210 | 210 | public function getErrorMessage() : string |
| 211 | 211 | { |
| 212 | 212 | return $this->getMessage(self::TYPE_ERROR); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Retrieves the success message, if one has been provided. |
|
| 217 | - * |
|
| 218 | - * @return string |
|
| 219 | - */ |
|
| 215 | + /** |
|
| 216 | + * Retrieves the success message, if one has been provided. |
|
| 217 | + * |
|
| 218 | + * @return string |
|
| 219 | + */ |
|
| 220 | 220 | public function getSuccessMessage() : string |
| 221 | 221 | { |
| 222 | 222 | return $this->getMessage(self::TYPE_SUCCESS); |
@@ -232,21 +232,21 @@ discard block |
||
| 232 | 232 | return $this->getMessage(self::TYPE_WARNING); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * Whether a specific error/success code has been specified. |
|
| 237 | - * |
|
| 238 | - * @return bool |
|
| 239 | - */ |
|
| 235 | + /** |
|
| 236 | + * Whether a specific error/success code has been specified. |
|
| 237 | + * |
|
| 238 | + * @return bool |
|
| 239 | + */ |
|
| 240 | 240 | public function hasCode() : bool |
| 241 | 241 | { |
| 242 | 242 | return $this->code > 0; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * Retrieves the error/success code, if any. |
|
| 247 | - * |
|
| 248 | - * @return int The error code, or 0 if none. |
|
| 249 | - */ |
|
| 245 | + /** |
|
| 246 | + * Retrieves the error/success code, if any. |
|
| 247 | + * |
|
| 248 | + * @return int The error code, or 0 if none. |
|
| 249 | + */ |
|
| 250 | 250 | public function getCode() : int |
| 251 | 251 | { |
| 252 | 252 | return $this->code; |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * @see Microtime::createFromString() |
| 115 | 115 | * @see Microtime::createNow() |
| 116 | 116 | */ |
| 117 | - public function __construct($datetime=self::DATETIME_NOW, ?DateTimeZone $timeZone=null) |
|
| 117 | + public function __construct($datetime = self::DATETIME_NOW, ?DateTimeZone $timeZone = null) |
|
| 118 | 118 | { |
| 119 | - if($datetime instanceof Microtime_ParseResult) |
|
| 119 | + if ($datetime instanceof Microtime_ParseResult) |
|
| 120 | 120 | { |
| 121 | 121 | $parsed = $datetime; |
| 122 | 122 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | * @return Microtime_ParseResult |
| 149 | 149 | * @throws Microtime_Exception |
| 150 | 150 | */ |
| 151 | - private function parseDate($datetime, ?DateTimeZone $timeZone=null) : Microtime_ParseResult |
|
| 151 | + private function parseDate($datetime, ?DateTimeZone $timeZone = null) : Microtime_ParseResult |
|
| 152 | 152 | { |
| 153 | - if($datetime instanceof Microtime) |
|
| 153 | + if ($datetime instanceof Microtime) |
|
| 154 | 154 | { |
| 155 | 155 | return new Microtime_ParseResult( |
| 156 | 156 | $datetime->getISODate(), |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($datetime instanceof DateTime) |
|
| 161 | + if ($datetime instanceof DateTime) |
|
| 162 | 162 | { |
| 163 | 163 | return new Microtime_ParseResult( |
| 164 | 164 | $datetime->format(self::FORMAT_ISO), |
@@ -166,17 +166,17 @@ discard block |
||
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if($timeZone === null) |
|
| 169 | + if ($timeZone === null) |
|
| 170 | 170 | { |
| 171 | 171 | $timeZone = new DateTimeZone(date_default_timezone_get()); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if(empty($datetime) || $datetime === self::DATETIME_NOW) |
|
| 174 | + if (empty($datetime) || $datetime === self::DATETIME_NOW) |
|
| 175 | 175 | { |
| 176 | 176 | return self::parseNow($timeZone); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if(is_string($datetime)) |
|
| 179 | + if (is_string($datetime)) |
|
| 180 | 180 | { |
| 181 | 181 | return new Microtime_ParseResult( |
| 182 | 182 | $datetime, |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $dateObj = DateTime::createFromFormat('0.u00 U', microtime(), new DateTimeZone('America/Denver')); |
| 205 | 205 | |
| 206 | - if($dateObj !== false) |
|
| 206 | + if ($dateObj !== false) |
|
| 207 | 207 | { |
| 208 | 208 | $dateObj->setTimezone($timeZone); |
| 209 | 209 | |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | * @return Microtime |
| 228 | 228 | * @throws Microtime_Exception |
| 229 | 229 | */ |
| 230 | - public static function createNow(?DateTimeZone $timeZone=null) : Microtime |
|
| 230 | + public static function createNow(?DateTimeZone $timeZone = null) : Microtime |
|
| 231 | 231 | { |
| 232 | - if($timeZone === null) |
|
| 232 | + if ($timeZone === null) |
|
| 233 | 233 | { |
| 234 | 234 | $timeZone = new DateTimeZone(date_default_timezone_get()); |
| 235 | 235 | } |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | * @return Microtime |
| 247 | 247 | * @throws Microtime_Exception |
| 248 | 248 | */ |
| 249 | - public static function createFromString(string $date, ?DateTimeZone $timeZone=null) : Microtime |
|
| 249 | + public static function createFromString(string $date, ?DateTimeZone $timeZone = null) : Microtime |
|
| 250 | 250 | { |
| 251 | - if($timeZone === null) |
|
| 251 | + if ($timeZone === null) |
|
| 252 | 252 | { |
| 253 | 253 | $timeZone = new DateTimeZone(date_default_timezone_get()); |
| 254 | 254 | } |
@@ -119,8 +119,7 @@ discard block |
||
| 119 | 119 | if($datetime instanceof Microtime_ParseResult) |
| 120 | 120 | { |
| 121 | 121 | $parsed = $datetime; |
| 122 | - } |
|
| 123 | - else |
|
| 122 | + } else |
|
| 124 | 123 | { |
| 125 | 124 | $parsed = $this->parseDate($datetime, $timeZone); |
| 126 | 125 | } |
@@ -128,8 +127,7 @@ discard block |
||
| 128 | 127 | try |
| 129 | 128 | { |
| 130 | 129 | parent::__construct($parsed->getDateTime(), $parsed->getTimeZone()); |
| 131 | - } |
|
| 132 | - catch (Exception $e) |
|
| 130 | + } catch (Exception $e) |
|
| 133 | 131 | { |
| 134 | 132 | throw new Microtime_Exception( |
| 135 | 133 | 'Failed to create date from string.', |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | protected function __construct($subject) |
| 82 | 82 | { |
| 83 | - if(is_array($subject)) |
|
| 83 | + if (is_array($subject)) |
|
| 84 | 84 | { |
| 85 | 85 | $this->parseSerialized($subject); |
| 86 | 86 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function getPrevious() : ConvertHelper_ThrowableInfo |
| 141 | 141 | { |
| 142 | - if(isset($this->previous)) { |
|
| 142 | + if (isset($this->previous)) { |
|
| 143 | 143 | return $this->previous; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | public function getFolderDepth() : int |
| 259 | 259 | { |
| 260 | 260 | $depth = $this->getOption('folder-depth'); |
| 261 | - if(!empty($depth)) { |
|
| 261 | + if (!empty($depth)) { |
|
| 262 | 262 | return $depth; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | $this->setOptions($serialized[ConvertHelper_ThrowableInfo_Serializer::SERIALIZED_OPTIONS]); |
| 317 | 317 | |
| 318 | - foreach($serialized[ConvertHelper_ThrowableInfo_Serializer::SERIALIZED_CALLS] as $def) |
|
| 318 | + foreach ($serialized[ConvertHelper_ThrowableInfo_Serializer::SERIALIZED_CALLS] as $def) |
|
| 319 | 319 | { |
| 320 | 320 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromSerialized($this, $def); |
| 321 | 321 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $this->date = new Microtime(); |
| 327 | 327 | $this->class = get_class($e); |
| 328 | 328 | |
| 329 | - if($e instanceof BaseException) |
|
| 329 | + if ($e instanceof BaseException) |
|
| 330 | 330 | { |
| 331 | 331 | $this->details = $e->getDetails(); |
| 332 | 332 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * @return string |
| 360 | 360 | * @throws ConvertHelper_Exception |
| 361 | 361 | */ |
| 362 | - public function renderErrorMessage(bool $withDeveloperInfo=false) : string |
|
| 362 | + public function renderErrorMessage(bool $withDeveloperInfo = false) : string |
|
| 363 | 363 | { |
| 364 | 364 | return (new ConvertHelper_ThrowableInfo_MessageRenderer($this, $withDeveloperInfo)) |
| 365 | 365 | ->render(); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | else |
| 437 | 437 | { |
| 438 | - $this->message = 'Original error code: [' . $code . ']. ' . $this->message; |
|
| 438 | + $this->message = 'Original error code: ['.$code.']. '.$this->message; |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | |
@@ -83,8 +83,7 @@ discard block |
||
| 83 | 83 | if(is_array($subject)) |
| 84 | 84 | { |
| 85 | 85 | $this->parseSerialized($subject); |
| 86 | - } |
|
| 87 | - else |
|
| 86 | + } else |
|
| 88 | 87 | { |
| 89 | 88 | $this->parseException($subject); |
| 90 | 89 | } |
@@ -432,8 +431,7 @@ discard block |
||
| 432 | 431 | if (is_integer($code)) |
| 433 | 432 | { |
| 434 | 433 | $this->code = $code; |
| 435 | - } |
|
| 436 | - else |
|
| 434 | + } else |
|
| 437 | 435 | { |
| 438 | 436 | $this->message = 'Original error code: [' . $code . ']. ' . $this->message; |
| 439 | 437 | } |
@@ -20,48 +20,48 @@ discard block |
||
| 20 | 20 | public const CONTEXT_WEB = 'web'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * @var Throwable |
|
| 24 | - */ |
|
| 23 | + * @var Throwable |
|
| 24 | + */ |
|
| 25 | 25 | protected $exception; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var ConvertHelper_ThrowableInfo_Call[] |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var ConvertHelper_ThrowableInfo_Call[] |
|
| 29 | + */ |
|
| 30 | 30 | protected $calls = array(); |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var integer |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var integer |
|
| 34 | + */ |
|
| 35 | 35 | protected $code = 0; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | 40 | protected $message; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var integer |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var integer |
|
| 44 | + */ |
|
| 45 | 45 | protected $callsCount = 0; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var ConvertHelper_ThrowableInfo|NULL |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var ConvertHelper_ThrowableInfo|NULL |
|
| 49 | + */ |
|
| 50 | 50 | protected $previous = null; |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 52 | + /** |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | 55 | protected $referer = ''; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var Microtime |
|
| 59 | - */ |
|
| 57 | + /** |
|
| 58 | + * @var Microtime |
|
| 59 | + */ |
|
| 60 | 60 | protected $date; |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var string |
|
| 64 | - */ |
|
| 62 | + /** |
|
| 63 | + * @var string |
|
| 64 | + */ |
|
| 65 | 65 | protected $context = self::CONTEXT_WEB; |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -127,16 +127,16 @@ discard block |
||
| 127 | 127 | return isset($this->previous); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Retrieves the information on the previous exception. |
|
| 132 | - * |
|
| 133 | - * NOTE: Throws an exception if there is no previous |
|
| 134 | - * exception. Use hasPrevious() first to avoid this. |
|
| 135 | - * |
|
| 136 | - * @throws ConvertHelper_Exception |
|
| 137 | - * @return ConvertHelper_ThrowableInfo |
|
| 138 | - * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
| 139 | - */ |
|
| 130 | + /** |
|
| 131 | + * Retrieves the information on the previous exception. |
|
| 132 | + * |
|
| 133 | + * NOTE: Throws an exception if there is no previous |
|
| 134 | + * exception. Use hasPrevious() first to avoid this. |
|
| 135 | + * |
|
| 136 | + * @throws ConvertHelper_Exception |
|
| 137 | + * @return ConvertHelper_ThrowableInfo |
|
| 138 | + * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
| 139 | + */ |
|
| 140 | 140 | public function getPrevious() : ConvertHelper_ThrowableInfo |
| 141 | 141 | { |
| 142 | 142 | if(isset($this->previous)) { |
@@ -155,68 +155,68 @@ discard block |
||
| 155 | 155 | return !empty($this->code); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Improved text-only exception trace. |
|
| 160 | - */ |
|
| 158 | + /** |
|
| 159 | + * Improved text-only exception trace. |
|
| 160 | + */ |
|
| 161 | 161 | public function toString() : string |
| 162 | 162 | { |
| 163 | 163 | return (new ConvertHelper_ThrowableInfo_StringConverter($this)) |
| 164 | 164 | ->toString(); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Retrieves the URL of the page in which the exception |
|
| 169 | - * was thrown, if applicable: in CLI context, this will |
|
| 170 | - * return an empty string. |
|
| 171 | - * |
|
| 172 | - * @return string |
|
| 173 | - */ |
|
| 167 | + /** |
|
| 168 | + * Retrieves the URL of the page in which the exception |
|
| 169 | + * was thrown, if applicable: in CLI context, this will |
|
| 170 | + * return an empty string. |
|
| 171 | + * |
|
| 172 | + * @return string |
|
| 173 | + */ |
|
| 174 | 174 | public function getReferer() : string |
| 175 | 175 | { |
| 176 | 176 | return $this->referer; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Whether the exception occurred in a command line context. |
|
| 181 | - * @return bool |
|
| 182 | - */ |
|
| 179 | + /** |
|
| 180 | + * Whether the exception occurred in a command line context. |
|
| 181 | + * @return bool |
|
| 182 | + */ |
|
| 183 | 183 | public function isCommandLine() : bool |
| 184 | 184 | { |
| 185 | 185 | return $this->getContext() === self::CONTEXT_COMMAND_LINE; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Whether the exception occurred during an http request. |
|
| 190 | - * @return bool |
|
| 191 | - */ |
|
| 188 | + /** |
|
| 189 | + * Whether the exception occurred during an http request. |
|
| 190 | + * @return bool |
|
| 191 | + */ |
|
| 192 | 192 | public function isWebRequest() : bool |
| 193 | 193 | { |
| 194 | 194 | return $this->getContext() === self::CONTEXT_WEB; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Retrieves the context identifier, i.e. if the exception |
|
| 199 | - * occurred in a command line context or regular web request. |
|
| 200 | - * |
|
| 201 | - * @return string |
|
| 202 | - * |
|
| 203 | - * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
| 204 | - * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
| 205 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
| 206 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
| 207 | - */ |
|
| 197 | + /** |
|
| 198 | + * Retrieves the context identifier, i.e. if the exception |
|
| 199 | + * occurred in a command line context or regular web request. |
|
| 200 | + * |
|
| 201 | + * @return string |
|
| 202 | + * |
|
| 203 | + * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
| 204 | + * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
| 205 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
| 206 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
| 207 | + */ |
|
| 208 | 208 | public function getContext() : string |
| 209 | 209 | { |
| 210 | 210 | return $this->context; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Retrieves the date of the exception, and approximate time: |
|
| 215 | - * since exceptions do not store time, this is captured the |
|
| 216 | - * moment the ThrowableInfo is created. |
|
| 217 | - * |
|
| 218 | - * @return Microtime |
|
| 219 | - */ |
|
| 213 | + /** |
|
| 214 | + * Retrieves the date of the exception, and approximate time: |
|
| 215 | + * since exceptions do not store time, this is captured the |
|
| 216 | + * moment the ThrowableInfo is created. |
|
| 217 | + * |
|
| 218 | + * @return Microtime |
|
| 219 | + */ |
|
| 220 | 220 | public function getDate() : Microtime |
| 221 | 221 | { |
| 222 | 222 | return $this->date; |
@@ -237,24 +237,24 @@ discard block |
||
| 237 | 237 | return ConvertHelper_ThrowableInfo_Serializer::serialize($this); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * Sets the maximum folder depth to show in the |
|
| 242 | - * file paths, to avoid them being too long. |
|
| 243 | - * |
|
| 244 | - * @param int $depth |
|
| 245 | - * @return ConvertHelper_ThrowableInfo |
|
| 246 | - */ |
|
| 240 | + /** |
|
| 241 | + * Sets the maximum folder depth to show in the |
|
| 242 | + * file paths, to avoid them being too long. |
|
| 243 | + * |
|
| 244 | + * @param int $depth |
|
| 245 | + * @return ConvertHelper_ThrowableInfo |
|
| 246 | + */ |
|
| 247 | 247 | public function setFolderDepth(int $depth) : ConvertHelper_ThrowableInfo |
| 248 | 248 | { |
| 249 | 249 | return $this->setOption('folder-depth', $depth); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * Retrieves the current folder depth option value. |
|
| 254 | - * |
|
| 255 | - * @return int |
|
| 256 | - * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
| 257 | - */ |
|
| 252 | + /** |
|
| 253 | + * Retrieves the current folder depth option value. |
|
| 254 | + * |
|
| 255 | + * @return int |
|
| 256 | + * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
| 257 | + */ |
|
| 258 | 258 | public function getFolderDepth() : int |
| 259 | 259 | { |
| 260 | 260 | $depth = $this->getOption('folder-depth'); |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | return 2; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Retrieves all function calls that led to the error, |
|
| 270 | - * ordered from latest to earliest (the first one in |
|
| 271 | - * the stack is actually the last call). |
|
| 272 | - * |
|
| 273 | - * @return ConvertHelper_ThrowableInfo_Call[] |
|
| 274 | - */ |
|
| 268 | + /** |
|
| 269 | + * Retrieves all function calls that led to the error, |
|
| 270 | + * ordered from latest to earliest (the first one in |
|
| 271 | + * the stack is actually the last call). |
|
| 272 | + * |
|
| 273 | + * @return ConvertHelper_ThrowableInfo_Call[] |
|
| 274 | + */ |
|
| 275 | 275 | public function getCalls() |
| 276 | 276 | { |
| 277 | 277 | return $this->calls; |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | return $this->calls[0]; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Returns the amount of function and method calls in the stack trace. |
|
| 292 | - * @return int |
|
| 293 | - */ |
|
| 290 | + /** |
|
| 291 | + * Returns the amount of function and method calls in the stack trace. |
|
| 292 | + * @return int |
|
| 293 | + */ |
|
| 294 | 294 | public function countCalls() : int |
| 295 | 295 | { |
| 296 | 296 | return $this->callsCount; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | ->t('Message:') |
| 39 | 39 | ->add($this->info->getMessage()); |
| 40 | 40 | |
| 41 | - if($this->developerInfo) |
|
| 41 | + if ($this->developerInfo) |
|
| 42 | 42 | { |
| 43 | 43 | $message |
| 44 | 44 | ->eol() |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | ->add($finalCall->toString()); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if($this->developerInfo && $this->info->hasDetails()) |
|
| 49 | + if ($this->developerInfo && $this->info->hasDetails()) |
|
| 50 | 50 | { |
| 51 | 51 | $message |
| 52 | 52 | ->t('Developer details:') |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | ->add($this->info->getDetails()); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if($this->info->hasPrevious()) |
|
| 57 | + if ($this->info->hasPrevious()) |
|
| 58 | 58 | { |
| 59 | 59 | $message |
| 60 | 60 | ->eol() |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | self::SERIALIZED_PREVIOUS => null, |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - if($info->hasPrevious()) |
|
| 42 | + if ($info->hasPrevious()) |
|
| 43 | 43 | { |
| 44 | 44 | $result[self::SERIALIZED_PREVIOUS] = $info->getPrevious()->serialize(); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $calls = $info->getCalls(); |
| 48 | - foreach($calls as $call) |
|
| 48 | + foreach ($calls as $call) |
|
| 49 | 49 | { |
| 50 | 50 | $result[self::SERIALIZED_CALLS][] = $call->serialize(); |
| 51 | 51 | } |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | $data = self::validateSerializedData($serialized); |
| 64 | 64 | $data[self::SERIALIZED_PREVIOUS] = self::unserializePrevious($data[self::SERIALIZED_PREVIOUS]); |
| 65 | 65 | |
| 66 | - if(!isset($data[self::SERIALIZED_CLASS])) |
|
| 66 | + if (!isset($data[self::SERIALIZED_CLASS])) |
|
| 67 | 67 | { |
| 68 | 68 | $data[self::SERIALIZED_CLASS] = ''; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if(!isset($data[self::SERIALIZED_DETAILS])) |
|
| 71 | + if (!isset($data[self::SERIALIZED_DETAILS])) |
|
| 72 | 72 | { |
| 73 | 73 | $data[self::SERIALIZED_DETAILS] = ''; |
| 74 | 74 | } |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | self::SERIALIZED_CALLS => 'array' |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | - foreach($keys as $key => $type) |
|
| 97 | + foreach ($keys as $key => $type) |
|
| 98 | 98 | { |
| 99 | - if(!isset($serialized[$key]) || gettype($serialized[$key]) !== $type) |
|
| 99 | + if (!isset($serialized[$key]) || gettype($serialized[$key]) !== $type) |
|
| 100 | 100 | { |
| 101 | 101 | throw self::createTypeException($key, $type); |
| 102 | 102 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | private static function unserializePrevious(?array $previous) : ?ConvertHelper_ThrowableInfo |
| 122 | 122 | { |
| 123 | - if(!empty($previous)) |
|
| 123 | + if (!empty($previous)) |
|
| 124 | 124 | { |
| 125 | 125 | return ConvertHelper_ThrowableInfo::fromSerialized($previous); |
| 126 | 126 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | public function toString() : string |
| 20 | 20 | { |
| 21 | 21 | return |
| 22 | - $this->renderMessage() . |
|
| 23 | - $this->renderCalls() . |
|
| 22 | + $this->renderMessage(). |
|
| 23 | + $this->renderCalls(). |
|
| 24 | 24 | $this->renderPrevious(); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | if ($this->info->hasCode()) |
| 35 | 35 | { |
| 36 | - $string .= ' #' . $this->info->getCode(); |
|
| 36 | + $string .= ' #'.$this->info->getCode(); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $string .= |
| 40 | - ': ' . |
|
| 41 | - $this->info->getMessage() . |
|
| 40 | + ': '. |
|
| 41 | + $this->info->getMessage(). |
|
| 42 | 42 | PHP_EOL; |
| 43 | 43 | |
| 44 | 44 | return $string; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | foreach ($calls as $call) |
| 57 | 57 | { |
| 58 | - $string .= $call->toString() . PHP_EOL; |
|
| 58 | + $string .= $call->toString().PHP_EOL; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $string; |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return |
| 76 | - PHP_EOL . |
|
| 77 | - PHP_EOL . |
|
| 78 | - 'Previous error:' . |
|
| 79 | - PHP_EOL . |
|
| 80 | - PHP_EOL . |
|
| 76 | + PHP_EOL. |
|
| 77 | + PHP_EOL. |
|
| 78 | + 'Previous error:'. |
|
| 79 | + PHP_EOL. |
|
| 80 | + PHP_EOL. |
|
| 81 | 81 | $this->info->getPrevious()->toString(); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | return $this->name; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setSelfClosing(bool $selfClosing=true) : HTMLTag |
|
| 76 | + public function setSelfClosing(bool $selfClosing = true) : HTMLTag |
|
| 77 | 77 | { |
| 78 | 78 | $this->selfClosing = $selfClosing; |
| 79 | 79 | return $this; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return $this->selfClosing; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function setEmptyAllowed(bool $allowed=true) : HTMLTag |
|
| 87 | + public function setEmptyAllowed(bool $allowed = true) : HTMLTag |
|
| 88 | 88 | { |
| 89 | 89 | $this->allowEmpty = $allowed; |
| 90 | 90 | return $this; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function isEmptyAllowed() : bool |
| 94 | 94 | { |
| 95 | - if($this->isSelfClosing()) |
|
| 95 | + if ($this->isSelfClosing()) |
|
| 96 | 96 | { |
| 97 | 97 | return true; |
| 98 | 98 | } |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | return $this->allowEmpty; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public static function create(string $name, ?AttributeCollection $attributes=null) : HTMLTag |
|
| 103 | + public static function create(string $name, ?AttributeCollection $attributes = null) : HTMLTag |
|
| 104 | 104 | { |
| 105 | - if($attributes === null) |
|
| 105 | + if ($attributes === null) |
|
| 106 | 106 | { |
| 107 | 107 | $attributes = AttributeCollection::create(); |
| 108 | 108 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | public function render() : string |
| 130 | 130 | { |
| 131 | - if(!$this->isEmptyAllowed() && $this->isEmpty()) |
|
| 131 | + if (!$this->isEmptyAllowed() && $this->isEmpty()) |
|
| 132 | 132 | { |
| 133 | 133 | return ''; |
| 134 | 134 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | public static function getGlobalOptions() : GlobalOptions |
| 143 | 143 | { |
| 144 | - if(!isset(self::$globalOptions)) |
|
| 144 | + if (!isset(self::$globalOptions)) |
|
| 145 | 145 | { |
| 146 | 146 | self::$globalOptions = new GlobalOptions(); |
| 147 | 147 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | public function getSelfClosingChar() : string |
| 153 | 153 | { |
| 154 | - if($this->selfClosing && self::getGlobalOptions()->getSelfCloseStyle() === self::SELF_CLOSE_STYLE_SLASH) |
|
| 154 | + if ($this->selfClosing && self::getGlobalOptions()->getSelfCloseStyle() === self::SELF_CLOSE_STYLE_SLASH) |
|
| 155 | 155 | { |
| 156 | 156 | return '/'; |
| 157 | 157 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | public function renderClose() : string |
| 173 | 173 | { |
| 174 | - if($this->selfClosing) |
|
| 174 | + if ($this->selfClosing) |
|
| 175 | 175 | { |
| 176 | 176 | return ''; |
| 177 | 177 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | public function renderContent() : string |
| 213 | 213 | { |
| 214 | - if($this->selfClosing) |
|
| 214 | + if ($this->selfClosing) |
|
| 215 | 215 | { |
| 216 | 216 | return ''; |
| 217 | 217 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | return $this; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - public function prop(string $name, bool $enabled=true) : HTMLTag |
|
| 233 | + public function prop(string $name, bool $enabled = true) : HTMLTag |
|
| 234 | 234 | { |
| 235 | 235 | $this->attributes->prop($name, $enabled); |
| 236 | 236 | return $this; |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | 'WriteThreshold' => 100 |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | 44 | protected $file; |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var ZipArchive|NULL |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @var ZipArchive|NULL |
|
| 48 | + */ |
|
| 49 | 49 | protected $zip; |
| 50 | 50 | |
| 51 | 51 | public function __construct(string $targetFile) |
@@ -53,35 +53,35 @@ discard block |
||
| 53 | 53 | $this->file = $targetFile; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Sets an option, among the available options: |
|
| 58 | - * |
|
| 59 | - * <ul> |
|
| 60 | - * <li>WriteThreshold: The amount of files to add before the zip is automatically written to disk and re-opened to release the file handles. Set to 0 to disable.</li> |
|
| 61 | - * </ul> |
|
| 62 | - * |
|
| 63 | - * @param string $name |
|
| 64 | - * @param mixed $value |
|
| 65 | - * @return ZIPHelper |
|
| 66 | - */ |
|
| 56 | + /** |
|
| 57 | + * Sets an option, among the available options: |
|
| 58 | + * |
|
| 59 | + * <ul> |
|
| 60 | + * <li>WriteThreshold: The amount of files to add before the zip is automatically written to disk and re-opened to release the file handles. Set to 0 to disable.</li> |
|
| 61 | + * </ul> |
|
| 62 | + * |
|
| 63 | + * @param string $name |
|
| 64 | + * @param mixed $value |
|
| 65 | + * @return ZIPHelper |
|
| 66 | + */ |
|
| 67 | 67 | public function setOption(string $name, $value) : ZIPHelper |
| 68 | 68 | { |
| 69 | 69 | $this->options[$name] = $value; |
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Adds a file to the zip. By default, the file is stored |
|
| 75 | - * with the same name in the root of the zip. Use the optional |
|
| 76 | - * parameter to change the location in the zip. |
|
| 77 | - * |
|
| 78 | - * @param string $filePath |
|
| 79 | - * @param string|null $zipPath If no path is specified, file will be added with the same name in the ZIP's root. |
|
| 80 | - * @throws ZIPHelper_Exception |
|
| 81 | - * @return bool |
|
| 82 | - * |
|
| 83 | - * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
|
| 84 | - */ |
|
| 73 | + /** |
|
| 74 | + * Adds a file to the zip. By default, the file is stored |
|
| 75 | + * with the same name in the root of the zip. Use the optional |
|
| 76 | + * parameter to change the location in the zip. |
|
| 77 | + * |
|
| 78 | + * @param string $filePath |
|
| 79 | + * @param string|null $zipPath If no path is specified, file will be added with the same name in the ZIP's root. |
|
| 80 | + * @throws ZIPHelper_Exception |
|
| 81 | + * @return bool |
|
| 82 | + * |
|
| 83 | + * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
|
| 84 | + */ |
|
| 85 | 85 | public function addFile(string $filePath, ?string $zipPath=null) : bool |
| 86 | 86 | { |
| 87 | 87 | $this->open(); |
@@ -289,14 +289,14 @@ discard block |
||
| 289 | 289 | return $this; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - /** |
|
| 293 | - * Extracts all files and folders from the zip to the |
|
| 294 | - * target folder. If no folder is specified, the files |
|
| 295 | - * are extracted into the same folder as the zip itself. |
|
| 296 | - * |
|
| 297 | - * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
|
| 298 | - * @return boolean |
|
| 299 | - */ |
|
| 292 | + /** |
|
| 293 | + * Extracts all files and folders from the zip to the |
|
| 294 | + * target folder. If no folder is specified, the files |
|
| 295 | + * are extracted into the same folder as the zip itself. |
|
| 296 | + * |
|
| 297 | + * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
|
| 298 | + * @return boolean |
|
| 299 | + */ |
|
| 300 | 300 | public function extractAll(?string $outputFolder=null) : bool |
| 301 | 301 | { |
| 302 | 302 | if(empty($outputFolder)) { |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | return $this->zip->extractTo($outputFolder); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * @return ZipArchive |
|
| 313 | - */ |
|
| 311 | + /** |
|
| 312 | + * @return ZipArchive |
|
| 313 | + */ |
|
| 314 | 314 | public function getArchive() : ZipArchive |
| 315 | 315 | { |
| 316 | 316 | $this->open(); |
@@ -318,14 +318,14 @@ discard block |
||
| 318 | 318 | return $this->zip; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - /** |
|
| 322 | - * JSON encodes the specified data and adds the json as |
|
| 323 | - * a file in the ZIP archive. |
|
| 324 | - * |
|
| 325 | - * @param mixed $data |
|
| 326 | - * @param string $zipPath |
|
| 327 | - * @return boolean |
|
| 328 | - */ |
|
| 321 | + /** |
|
| 322 | + * JSON encodes the specified data and adds the json as |
|
| 323 | + * a file in the ZIP archive. |
|
| 324 | + * |
|
| 325 | + * @param mixed $data |
|
| 326 | + * @param string $zipPath |
|
| 327 | + * @return boolean |
|
| 328 | + */ |
|
| 329 | 329 | public function addJSON($data, string $zipPath) : bool |
| 330 | 330 | { |
| 331 | 331 | return $this->addString( |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public const ERROR_OPENING_ZIP_FILE = 338003; |
| 34 | 34 | |
| 35 | - public const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
| 35 | + public const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
| 36 | 36 | |
| 37 | 37 | protected $options = array( |
| 38 | 38 | 'WriteThreshold' => 100 |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
| 84 | 84 | */ |
| 85 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
| 85 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
| 86 | 86 | { |
| 87 | 87 | $this->open(); |
| 88 | 88 | |
@@ -135,16 +135,16 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected function open() : void |
| 137 | 137 | { |
| 138 | - if($this->open) { |
|
| 138 | + if ($this->open) { |
|
| 139 | 139 | return; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if(!isset($this->zip)) { |
|
| 142 | + if (!isset($this->zip)) { |
|
| 143 | 143 | $this->zip = new ZipArchive(); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $flag = null; |
| 147 | - if(!file_exists($this->file)) { |
|
| 147 | + if (!file_exists($this->file)) { |
|
| 148 | 148 | $flag = ZipArchive::CREATE; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | $this->fileTracker++; |
| 189 | 189 | |
| 190 | - if($this->options['WriteThreshold'] < 1) { |
|
| 190 | + if ($this->options['WriteThreshold'] < 1) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | protected function close() : void |
| 202 | 202 | { |
| 203 | - if(!$this->open) { |
|
| 203 | + if (!$this->open) { |
|
| 204 | 204 | return; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | throw new ZIPHelper_Exception( |
| 210 | 210 | 'Could not save ZIP file to disk', |
| 211 | 211 | sprintf( |
| 212 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
| 213 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
| 212 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
| 213 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
| 214 | 214 | 'or trying to save to a directory that does not exist.', |
| 215 | 215 | $this->file |
| 216 | 216 | ), |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | $this->open(); |
| 227 | 227 | |
| 228 | - if($this->countFiles() < 1) |
|
| 228 | + if ($this->countFiles() < 1) |
|
| 229 | 229 | { |
| 230 | 230 | throw new ZIPHelper_Exception( |
| 231 | 231 | 'No files in the zip file', |
@@ -251,18 +251,18 @@ discard block |
||
| 251 | 251 | * @throws ZIPHelper_Exception |
| 252 | 252 | * @return string The file name that was sent (useful in case none was specified). |
| 253 | 253 | */ |
| 254 | - public function download(?string $fileName=null) : string |
|
| 254 | + public function download(?string $fileName = null) : string |
|
| 255 | 255 | { |
| 256 | 256 | $this->save(); |
| 257 | 257 | |
| 258 | - if(empty($fileName)) |
|
| 258 | + if (empty($fileName)) |
|
| 259 | 259 | { |
| 260 | 260 | $fileName = basename($this->file); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | header('Content-type: application/zip'); |
| 264 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
| 265 | - header('Content-length: ' . filesize($this->file)); |
|
| 264 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
| 265 | + header('Content-length: '.filesize($this->file)); |
|
| 266 | 266 | header('Pragma: no-cache'); |
| 267 | 267 | header('Expires: 0'); |
| 268 | 268 | readfile($this->file); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @throws ZIPHelper_Exception |
| 281 | 281 | * @see ZIPHelper::download() |
| 282 | 282 | */ |
| 283 | - public function downloadAndDelete(?string $fileName=null) : ZIPHelper |
|
| 283 | + public function downloadAndDelete(?string $fileName = null) : ZIPHelper |
|
| 284 | 284 | { |
| 285 | 285 | $this->download($fileName); |
| 286 | 286 | |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
| 298 | 298 | * @return boolean |
| 299 | 299 | */ |
| 300 | - public function extractAll(?string $outputFolder=null) : bool |
|
| 300 | + public function extractAll(?string $outputFolder = null) : bool |
|
| 301 | 301 | { |
| 302 | - if(empty($outputFolder)) { |
|
| 302 | + if (empty($outputFolder)) { |
|
| 303 | 303 | $outputFolder = dirname($this->file); |
| 304 | 304 | } |
| 305 | 305 | |