@@ -1024,19 +1024,19 @@ discard block |
||
| 1024 | 1024 | |
| 1025 | 1025 | $value = $this->format($value); |
| 1026 | 1026 | |
| 1027 | - if ( null === $value ) { |
|
| 1027 | + if (null === $value) { |
|
| 1028 | 1028 | |
| 1029 | 1029 | return "NULL"; |
| 1030 | 1030 | |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - if ( false === $value ) { |
|
| 1033 | + if (false === $value) { |
|
| 1034 | 1034 | |
| 1035 | 1035 | return "'0'"; |
| 1036 | 1036 | |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - if ( true === $value ) { |
|
| 1039 | + if (true === $value) { |
|
| 1040 | 1040 | |
| 1041 | 1041 | return "'1'"; |
| 1042 | 1042 | |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | $identifier = explode(".", $identifier); |
| 1100 | 1100 | |
| 1101 | 1101 | $identifier = array_map( |
| 1102 | - function ($part) use ($delimiter) { |
|
| 1102 | + function($part) use ($delimiter) { |
|
| 1103 | 1103 | return $delimiter . str_replace($delimiter, $delimiter . $delimiter, $part) . $delimiter; |
| 1104 | 1104 | }, |
| 1105 | 1105 | $identifier |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'separator' => ',', |
| 147 | 147 | ], |
| 148 | 148 | ]; |
| 149 | - foreach($clausules as $key => $clausule) { |
|
| 149 | + foreach ($clausules as $key => $clausule) { |
|
| 150 | 150 | if (isset($this->clausules[$key])) { |
| 151 | 151 | $value = $this->clausules[$key]; |
| 152 | 152 | if (is_array($value)) { |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | 'separator' => ' ', |
| 203 | 203 | ] |
| 204 | 204 | ]; |
| 205 | - foreach($clausules as $key => $clausule) { |
|
| 205 | + foreach ($clausules as $key => $clausule) { |
|
| 206 | 206 | if (isset($this->clausules[$key])) { |
| 207 | 207 | $value = $this->clausules[$key]; |
| 208 | 208 | if (is_array($value)) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | 'separator' => ' ', |
| 245 | 245 | ] |
| 246 | 246 | ]; |
| 247 | - foreach($clausules as $key => $clausule) { |
|
| 247 | + foreach ($clausules as $key => $clausule) { |
|
| 248 | 248 | if (isset($this->clausules[$key])) { |
| 249 | 249 | $value = $this->clausules[$key]; |
| 250 | 250 | if (is_array($value)) { |
@@ -129,7 +129,7 @@ |
||
| 129 | 129 | } |
| 130 | 130 | break; |
| 131 | 131 | case 'object': |
| 132 | - if ( false !== ($id = array_search($var, self::$_objects, true)) ) { |
|
| 132 | + if (false !== ($id = array_search($var, self::$_objects, true))) { |
|
| 133 | 133 | self::$_output .= get_class($var) . '#' . ($id + 1) . '(...)'; |
| 134 | 134 | } elseif (self::$_depth <= $level) { |
| 135 | 135 | self::$_output .= get_class($var) . '(...)'; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public static function setDataTime($data, string $strftime='%d %B %Y', string $format = 'Y-m-d H:i:s') |
|
| 98 | + public static function setDataTime($data, string $strftime = '%d %B %Y', string $format = 'Y-m-d H:i:s') |
|
| 99 | 99 | { |
| 100 | 100 | $data = new \DateTime($data); |
| 101 | 101 | $data_f = $data->format($format); |
@@ -111,45 +111,45 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | public static function nicetime($date, array $translate = ["second", "minute", "hour", "day", "week", "month", "year", "decade"]) |
| 113 | 113 | { |
| 114 | - if(empty($date)) { |
|
| 114 | + if (empty($date)) { |
|
| 115 | 115 | return "No date provided"; |
| 116 | 116 | } |
| 117 | - if(!is_array($translate)) { |
|
| 117 | + if (!is_array($translate)) { |
|
| 118 | 118 | return "the expected value is not an array"; |
| 119 | 119 | } |
| 120 | - if( 5 > count($translate)){ |
|
| 120 | + if (5 > count($translate)) { |
|
| 121 | 121 | return "the matrix needs 5 to 8 values (second, minute, hour, day, week,month, year, decade)"; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $periods = $translate; |
| 125 | - $lengths = array("60","60","24","7","4.35","12","10"); |
|
| 125 | + $lengths = array("60", "60", "24", "7", "4.35", "12", "10"); |
|
| 126 | 126 | |
| 127 | 127 | $now = time(); |
| 128 | - $unix_date = strtotime($date); |
|
| 128 | + $unix_date = strtotime($date); |
|
| 129 | 129 | |
| 130 | 130 | // check validity of date |
| 131 | - if(empty($unix_date)) { |
|
| 131 | + if (empty($unix_date)) { |
|
| 132 | 132 | return "Bad date"; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // is it future date or past date |
| 136 | - if($now > $unix_date) { |
|
| 137 | - $difference = $now - $unix_date; |
|
| 138 | - $tense = "ago"; |
|
| 136 | + if ($now > $unix_date) { |
|
| 137 | + $difference = $now - $unix_date; |
|
| 138 | + $tense = "ago"; |
|
| 139 | 139 | |
| 140 | 140 | } else { |
| 141 | - $difference = $unix_date - $now; |
|
| 142 | - $tense = "from now"; |
|
| 141 | + $difference = $unix_date - $now; |
|
| 142 | + $tense = "from now"; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { |
|
| 145 | + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) { |
|
| 146 | 146 | $difference /= $lengths[$j]; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $difference = round($difference); |
| 150 | 150 | |
| 151 | - if($difference != 1) { |
|
| 152 | - $periods[$j].= "s"; |
|
| 151 | + if ($difference != 1) { |
|
| 152 | + $periods[$j] .= "s"; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return "$difference $periods[$j] {$tense}"; |
@@ -48,42 +48,42 @@ |
||
| 48 | 48 | |
| 49 | 49 | public static function abbreviate($strString, $intLength = NULL) |
| 50 | 50 | { |
| 51 | - $defaultAbbrevLength = 8; //Default abbreviation length if none is specified |
|
| 51 | + $defaultAbbrevLength = 8; //Default abbreviation length if none is specified |
|
| 52 | 52 | |
| 53 | 53 | //Set up the string for processing |
| 54 | - $strString = preg_replace("/[^A-Za-z0-9]/", '', $strString); //Remove non-alphanumeric characters |
|
| 55 | - $strString = ucfirst($strString); //Capitalize the first character (helps with abbreviation calcs) |
|
| 54 | + $strString = preg_replace("/[^A-Za-z0-9]/", '', $strString); //Remove non-alphanumeric characters |
|
| 55 | + $strString = ucfirst($strString); //Capitalize the first character (helps with abbreviation calcs) |
|
| 56 | 56 | $stringIndex = 0; |
| 57 | 57 | //Figure out everything we need to know about the resulting abbreviation string |
| 58 | - $uppercaseCount = preg_match_all('/[A-Z]/', $strString, $uppercaseLetters, PREG_OFFSET_CAPTURE); //Record occurences of uppercase letters and their indecies in the $uppercaseLetters array, take note of how many there are |
|
| 59 | - $targetLength = isset($intLength) ? intval($intLength) : $defaultAbbrevLength; //Maximum length of the abbreviation |
|
| 60 | - $uppercaseCount = $uppercaseCount > $targetLength ? $targetLength : $uppercaseCount; //If there are more uppercase letters than the target length, adjust uppercaseCount to ignore overflow |
|
| 61 | - $targetWordLength = round($targetLength / intval($uppercaseCount)); //How many characters need to be taken from each uppercase-designated "word" in order to best meet the target length? |
|
| 62 | - $abbrevLength = 0; //How long the abbreviation currently is |
|
| 63 | - $abbreviation = ''; //The actual abbreviation |
|
| 58 | + $uppercaseCount = preg_match_all('/[A-Z]/', $strString, $uppercaseLetters, PREG_OFFSET_CAPTURE); //Record occurences of uppercase letters and their indecies in the $uppercaseLetters array, take note of how many there are |
|
| 59 | + $targetLength = isset($intLength) ? intval($intLength) : $defaultAbbrevLength; //Maximum length of the abbreviation |
|
| 60 | + $uppercaseCount = $uppercaseCount > $targetLength ? $targetLength : $uppercaseCount; //If there are more uppercase letters than the target length, adjust uppercaseCount to ignore overflow |
|
| 61 | + $targetWordLength = round($targetLength / intval($uppercaseCount)); //How many characters need to be taken from each uppercase-designated "word" in order to best meet the target length? |
|
| 62 | + $abbrevLength = 0; //How long the abbreviation currently is |
|
| 63 | + $abbreviation = ''; //The actual abbreviation |
|
| 64 | 64 | //Create respective arrays for the occurence indecies and the actual characters of uppercase characters within the string |
| 65 | 65 | for ($i = 0; $i < $uppercaseCount; $i++) { |
| 66 | 66 | //$ucIndicies[] = $uppercaseLetters[1]; //Not actually used. Could be used to calculate abbreviations more efficiently than the routine below by strictly considering indecies |
| 67 | 67 | $ucLetters[] = $uppercaseLetters[0][$i][0]; |
| 68 | 68 | } |
| 69 | - $characterDeficit = 0; //Gets incremented when an uppercase letter is encountered before $targetCharsPerWord characters have been collected since the last UC char. |
|
| 70 | - $wordIndex = $targetWordLength; //HACK: keeps track of how many characters have been carried into the abbreviation since the last UC char |
|
| 69 | + $characterDeficit = 0; //Gets incremented when an uppercase letter is encountered before $targetCharsPerWord characters have been collected since the last UC char. |
|
| 70 | + $wordIndex = $targetWordLength; //HACK: keeps track of how many characters have been carried into the abbreviation since the last UC char |
|
| 71 | 71 | while ($stringIndex < strlen($strString)) { //Process the whole input string... |
| 72 | 72 | if ($abbrevLength >= $targetLength) //...unless the abbreviation has hit the target length cap |
| 73 | 73 | break; |
| 74 | - $currentChar = $strString[$stringIndex++]; //Grab a character from the string, advance the string cursor |
|
| 74 | + $currentChar = $strString[$stringIndex++]; //Grab a character from the string, advance the string cursor |
|
| 75 | 75 | if (in_array($currentChar, $ucLetters)) { //If handling a UC char, consider it a new word |
| 76 | - $characterDeficit += $targetWordLength - $wordIndex; //If UC chars are closer together than targetWordLength, keeps track of how many extra characters are required to fit the target length of the abbreviation |
|
| 77 | - $wordIndex = 0; //Set the wordIndex to reflect a new word |
|
| 76 | + $characterDeficit += $targetWordLength - $wordIndex; //If UC chars are closer together than targetWordLength, keeps track of how many extra characters are required to fit the target length of the abbreviation |
|
| 77 | + $wordIndex = 0; //Set the wordIndex to reflect a new word |
|
| 78 | 78 | } else if ($wordIndex >= $targetWordLength) { |
| 79 | 79 | if ($characterDeficit == 0) //If the word is full and we're not short any characters, ignore the character |
| 80 | 80 | continue; |
| 81 | 81 | else |
| 82 | - $characterDefecit--; //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation |
|
| 82 | + $characterDefecit--; //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation |
|
| 83 | 83 | } |
| 84 | - $abbreviation .= $currentChar; //Add the character to the abbreviation |
|
| 85 | - $abbrevLength++; //Increment abbreviation length |
|
| 86 | - $wordIndex++; //Increment the number of characters for this word |
|
| 84 | + $abbreviation .= $currentChar; //Add the character to the abbreviation |
|
| 85 | + $abbrevLength++; //Increment abbreviation length |
|
| 86 | + $wordIndex++; //Increment the number of characters for this word |
|
| 87 | 87 | } |
| 88 | 88 | return $abbreviation; |
| 89 | 89 | } |
@@ -71,6 +71,6 @@ |
||
| 71 | 71 | if (array_key_exists($method, $this->__imported_functions)) { |
| 72 | 72 | return call_user_func_array(Array($this->__imported_functions[$method], $method), $array); |
| 73 | 73 | } |
| 74 | - throw new ErrorException ('Call to Undefined Method/Class Function', 0, E_ERROR); |
|
| 74 | + throw new ErrorException('Call to Undefined Method/Class Function', 0, E_ERROR); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | \ No newline at end of file |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | |
| 45 | 45 | public function digit(string $data) |
| 46 | 46 | { |
| 47 | - if ( false == ctype_digit($data) ) { |
|
| 47 | + if (false == ctype_digit($data)) { |
|
| 48 | 48 | return "Your string " . $data . " must be a digit"; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | public function text() |
| 152 | 152 | { |
| 153 | 153 | if (!is_string($this->_postData[$this->_currentItem])) { |
| 154 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Text'); |
|
| 154 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Text'); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return $this; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $email = filter_var($this->_postData[$this->_currentItem], FILTER_SANITIZE_EMAIL); |
| 163 | 163 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 164 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Email'); |
|
| 164 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Email'); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return $this; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | public function numeric() |
| 171 | 171 | { |
| 172 | 172 | if (!is_numeric($this->_postData[$this->_currentItem])) { |
| 173 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Numeric'); |
|
| 173 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Numeric'); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | return $this; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | public function int() |
| 180 | 180 | { |
| 181 | 181 | if (!intval($this->_postData[$this->_currentItem])) { |
| 182 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Int'); |
|
| 182 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Int'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return $this; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | public function long() |
| 189 | 189 | { |
| 190 | 190 | if (!floatval($this->_postData[$this->_currentItem])) { |
| 191 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Long'); |
|
| 191 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Long'); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | return $this; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | public function domain() |
| 198 | 198 | { |
| 199 | 199 | if (!filter_var($this->_postData[$this->_currentItem], FILTER_VALIDATE_DOMAIN)) { |
| 200 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Domain'); |
|
| 200 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Domain'); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | return $this; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | public function url() |
| 207 | 207 | { |
| 208 | 208 | if (!filter_var($this->_postData[$this->_currentItem], FILTER_VALIDATE_URL)) { |
| 209 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Url'); |
|
| 209 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Url'); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | return $this; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | public function ip() |
| 216 | 216 | { |
| 217 | 217 | if (!filter_var($this->_postData[$this->_currentItem], FILTER_VALIDATE_IP)) { |
| 218 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Ip'); |
|
| 218 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Ip'); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | return $this; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | public function date() |
| 225 | 225 | { |
| 226 | 226 | if (!is_string($this->_postData[$this->_currentItem])) { |
| 227 | - throw new \InvalidArgumentException('the value ('.$this->_postData[$this->_currentItem].') entered must have a Date'); |
|
| 227 | + throw new \InvalidArgumentException('the value (' . $this->_postData[$this->_currentItem] . ') entered must have a Date'); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | return $this; |
@@ -26,8 +26,8 @@ |
||
| 26 | 26 | /** |
| 27 | 27 | * @param string $message |
| 28 | 28 | */ |
| 29 | - public function write( $message, string $type = null) |
|
| 29 | + public function write($message, string $type = null) |
|
| 30 | 30 | { |
| 31 | - return $this->message =$message; |
|
| 31 | + return $this->message = $message; |
|
| 32 | 32 | } |
| 33 | 33 | } |