@@ -24,15 +24,15 @@ |
||
| 24 | 24 | { |
| 25 | 25 | public const ERROR_UNKNOWN_DATE_FORMAT_CHARACTER = 55501; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * The date format used in the date variable. This is used to convert |
|
| 29 | - * the native date to the format specified in the variable command. |
|
| 30 | - */ |
|
| 27 | + /** |
|
| 28 | + * The date format used in the date variable. This is used to convert |
|
| 29 | + * the native date to the format specified in the variable command. |
|
| 30 | + */ |
|
| 31 | 31 | public const DEFAULT_INTERNAL_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var string[]string |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var string[]string |
|
| 35 | + */ |
|
| 36 | 36 | private $charTable = array( |
| 37 | 37 | 'd' => 'dd', |
| 38 | 38 | 'j' => 'd', |
@@ -32,34 +32,34 @@ |
||
| 32 | 32 | public const VALIDATION_ERROR_PATH_UNDERSCORE = 48203; |
| 33 | 33 | public const VALIDATION_ERROR_NAME_UNDERSCORE = 48204; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | 38 | protected $path; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | 43 | protected $name; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | 48 | protected $matchedText; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | 53 | protected $hash = ''; |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @var OperationResult |
|
| 57 | - */ |
|
| 55 | + /** |
|
| 56 | + * @var OperationResult |
|
| 57 | + */ |
|
| 58 | 58 | protected $validationResult = null; |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var array<string> |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * @var array<string> |
|
| 62 | + */ |
|
| 63 | 63 | protected $validations = array( |
| 64 | 64 | 'number_path', |
| 65 | 65 | 'number_name', |
@@ -26,39 +26,39 @@ discard block |
||
| 26 | 26 | public const ERROR_INVALID_CALLABLE = 65701; |
| 27 | 27 | public const ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION = 65702; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | 32 | private $subject; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var integer |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var integer |
|
| 36 | + */ |
|
| 37 | 37 | private static $listenerCounter = 0; |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var callable[] |
|
| 41 | - */ |
|
| 39 | + /** |
|
| 40 | + * @var callable[] |
|
| 41 | + */ |
|
| 42 | 42 | private $listeners = array(); |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var boolean |
|
| 46 | - */ |
|
| 44 | + /** |
|
| 45 | + * @var boolean |
|
| 46 | + */ |
|
| 47 | 47 | private $updating = false; |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var integer |
|
| 51 | - */ |
|
| 49 | + /** |
|
| 50 | + * @var integer |
|
| 51 | + */ |
|
| 52 | 52 | private static $idCounter = 0; |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var integer |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * @var integer |
|
| 56 | + */ |
|
| 57 | 57 | private $id; |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @var integer |
|
| 61 | - */ |
|
| 59 | + /** |
|
| 60 | + * @var integer |
|
| 61 | + */ |
|
| 62 | 62 | private $length; |
| 63 | 63 | |
| 64 | 64 | public function __construct(string $subject) |
@@ -75,16 +75,16 @@ discard block |
||
| 75 | 75 | return $this->id; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Updates the string with the specified string. |
|
| 80 | - * Notifies all listeners of the change. |
|
| 81 | - * |
|
| 82 | - * @param string $subject |
|
| 83 | - * @throws Mailcode_Exception |
|
| 84 | - * @return bool Whether the string had modifications. |
|
| 85 | - * |
|
| 86 | - * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION |
|
| 87 | - */ |
|
| 78 | + /** |
|
| 79 | + * Updates the string with the specified string. |
|
| 80 | + * Notifies all listeners of the change. |
|
| 81 | + * |
|
| 82 | + * @param string $subject |
|
| 83 | + * @throws Mailcode_Exception |
|
| 84 | + * @return bool Whether the string had modifications. |
|
| 85 | + * |
|
| 86 | + * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION |
|
| 87 | + */ |
|
| 88 | 88 | public function updateString(string $subject) : bool |
| 89 | 89 | { |
| 90 | 90 | // avoid triggering an update if there are no changes in the string |
@@ -117,27 +117,27 @@ discard block |
||
| 117 | 117 | return true; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Retrieves the stored string. |
|
| 122 | - * |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 120 | + /** |
|
| 121 | + * Retrieves the stored string. |
|
| 122 | + * |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | 125 | public function getString() : string |
| 126 | 126 | { |
| 127 | 127 | return $this->subject; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Adds a listener that will be informed every time the string is modified. |
|
| 132 | - * The callback gets the string container instance as parameter. |
|
| 133 | - * |
|
| 134 | - * @param callable $callback |
|
| 135 | - * @throws Mailcode_Exception If it is not a valid callable. |
|
| 136 | - * @return int The listener number, to be able to remove it using `removeListener()`. |
|
| 137 | - * |
|
| 138 | - * @see Mailcode_StringContainer::removeListener() |
|
| 139 | - * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE |
|
| 140 | - */ |
|
| 130 | + /** |
|
| 131 | + * Adds a listener that will be informed every time the string is modified. |
|
| 132 | + * The callback gets the string container instance as parameter. |
|
| 133 | + * |
|
| 134 | + * @param callable $callback |
|
| 135 | + * @throws Mailcode_Exception If it is not a valid callable. |
|
| 136 | + * @return int The listener number, to be able to remove it using `removeListener()`. |
|
| 137 | + * |
|
| 138 | + * @see Mailcode_StringContainer::removeListener() |
|
| 139 | + * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE |
|
| 140 | + */ |
|
| 141 | 141 | public function addListener($callback) : int |
| 142 | 142 | { |
| 143 | 143 | self::$listenerCounter++; |
@@ -164,12 +164,12 @@ discard block |
||
| 164 | 164 | return $this->length; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Removes an existing listener by its ID. |
|
| 169 | - * Has no effect if it does not exist, or has already been removed. |
|
| 170 | - * |
|
| 171 | - * @param int $listenerID |
|
| 172 | - */ |
|
| 167 | + /** |
|
| 168 | + * Removes an existing listener by its ID. |
|
| 169 | + * Has no effect if it does not exist, or has already been removed. |
|
| 170 | + * |
|
| 171 | + * @param int $listenerID |
|
| 172 | + */ |
|
| 173 | 173 | public function removeListener(int $listenerID) : void |
| 174 | 174 | { |
| 175 | 175 | if(isset($this->listeners[$listenerID])) |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * Replaces all substrings matching needle with the replacement text. |
|
| 183 | - * |
|
| 184 | - * @param string $needle |
|
| 185 | - * @param string $replacement |
|
| 186 | - * @return bool |
|
| 187 | - */ |
|
| 181 | + /** |
|
| 182 | + * Replaces all substrings matching needle with the replacement text. |
|
| 183 | + * |
|
| 184 | + * @param string $needle |
|
| 185 | + * @param string $replacement |
|
| 186 | + * @return bool |
|
| 187 | + */ |
|
| 188 | 188 | public function replaceSubstrings(string $needle, string $replacement) : bool |
| 189 | 189 | { |
| 190 | 190 | $string = str_replace($needle, $replacement, $this->subject); |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | return $this->updateString($string); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * Get the position of a substring in the string. |
|
| 197 | - * |
|
| 198 | - * @param string $needle |
|
| 199 | - * @return int|bool The zero-based position, or false if not found. |
|
| 200 | - */ |
|
| 195 | + /** |
|
| 196 | + * Get the position of a substring in the string. |
|
| 197 | + * |
|
| 198 | + * @param string $needle |
|
| 199 | + * @return int|bool The zero-based position, or false if not found. |
|
| 200 | + */ |
|
| 201 | 201 | public function getSubstrPosition(string $needle) |
| 202 | 202 | { |
| 203 | 203 | return mb_strpos($this->subject, $needle); |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | '{\s*([a-z]+)\s+([a-z-]+)\s*:([^}]*)}' |
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var Mailcode |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var Mailcode |
|
| 33 | + */ |
|
| 34 | 34 | protected $mailcode; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var Mailcode_Commands |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var Mailcode_Commands |
|
| 38 | + */ |
|
| 39 | 39 | protected $commands; |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | $this->commands = $this->mailcode->getCommands(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Gets the regex format string used to detect commands. |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 52 | + /** |
|
| 53 | + * Gets the regex format string used to detect commands. |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | 57 | protected static function getRegex() : string |
| 58 | 58 | { |
| 59 | 59 | return '/'.implode('|', self::COMMAND_REGEX_PARTS).'/sixU'; |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | throw new Mailcode_Exception('Not a command', '', self::ERROR_NOT_A_COMMAND); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Parses a single regex match: determines which named group |
|
| 180 | - * matches, and retrieves the according information. |
|
| 181 | - * |
|
| 182 | - * @param array[] $matches The regex results array. |
|
| 183 | - * @param int $index The matched index. |
|
| 184 | - * @return Mailcode_Parser_Match |
|
| 185 | - */ |
|
| 178 | + /** |
|
| 179 | + * Parses a single regex match: determines which named group |
|
| 180 | + * matches, and retrieves the according information. |
|
| 181 | + * |
|
| 182 | + * @param array[] $matches The regex results array. |
|
| 183 | + * @param int $index The matched index. |
|
| 184 | + * @return Mailcode_Parser_Match |
|
| 185 | + */ |
|
| 186 | 186 | protected function parseMatch(array $matches, int $index) : Mailcode_Parser_Match |
| 187 | 187 | { |
| 188 | 188 | $name = ''; // the command name, e.g. "showvar" |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | ); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - /** |
|
| 224 | - * Creates an instance of the safeguard tool, which |
|
| 225 | - * is used to safeguard commands in a string with placeholders. |
|
| 226 | - * |
|
| 227 | - * @param string $subject The string to use to safeguard commands in. |
|
| 228 | - * @return Mailcode_Parser_Safeguard |
|
| 229 | - * @see Mailcode_Parser_Safeguard |
|
| 230 | - */ |
|
| 223 | + /** |
|
| 224 | + * Creates an instance of the safeguard tool, which |
|
| 225 | + * is used to safeguard commands in a string with placeholders. |
|
| 226 | + * |
|
| 227 | + * @param string $subject The string to use to safeguard commands in. |
|
| 228 | + * @return Mailcode_Parser_Safeguard |
|
| 229 | + * @see Mailcode_Parser_Safeguard |
|
| 230 | + */ |
|
| 231 | 231 | public function createSafeguard(string $subject) : Mailcode_Parser_Safeguard |
| 232 | 232 | { |
| 233 | 233 | return new Mailcode_Parser_Safeguard($this, $subject); |