@@ -28,7 +28,7 @@ |
||
| 28 | 28 | if ($command->isCountEnabled()) |
| 29 | 29 | { |
| 30 | 30 | $result = $this->buildCountAssignment($command); |
| 31 | - if($result !== null) { |
|
| 31 | + if ($result !== null) { |
|
| 32 | 32 | $assignmentString = $result; |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -26,6 +26,6 @@ |
||
| 26 | 26 | { |
| 27 | 27 | public function translate(Mailcode_Commands_Command_ShowPhone $command): string |
| 28 | 28 | { |
| 29 | - return '{{ ' . $command->getVariableName() . ' }}'; |
|
| 29 | + return '{{ '.$command->getVariableName().' }}'; |
|
| 30 | 30 | } |
| 31 | 31 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $varName = undollarize($name); |
| 44 | 44 | |
| 45 | - if(self::areVariableNamesLowercase()) { |
|
| 45 | + if (self::areVariableNamesLowercase()) { |
|
| 46 | 46 | $varName = strtolower($varName); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $variables = Mailcode::create()->createVariables()->parseString($subject)->getAll(); |
| 55 | 55 | |
| 56 | - foreach($variables as $variable) { |
|
| 56 | + foreach ($variables as $variable) { |
|
| 57 | 57 | $subject = str_replace($variable->getMatchedText(), $this->formatVariableName($variable->getFullName()), $subject); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | public const ERROR_UNKNOWN_COMMAND_TYPE = 50401; |
| 30 | 30 | public const ERROR_INVALID_COMMAND_INSTANCE = 50402; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | 35 | protected string $typeID; |
| 36 | 36 | |
| 37 | 37 | public function __construct(string $typeID) |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | $this->typeID = $typeID; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Retrieves the syntax's type ID, e.g. "ApacheVelocity". |
|
| 44 | - * @return string |
|
| 45 | - */ |
|
| 42 | + /** |
|
| 43 | + * Retrieves the syntax's type ID, e.g. "ApacheVelocity". |
|
| 44 | + * @return string |
|
| 45 | + */ |
|
| 46 | 46 | public function getTypeID() : string |
| 47 | 47 | { |
| 48 | 48 | return $this->typeID; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Translates a single command to the target syntax. |
|
| 53 | - * |
|
| 54 | - * @param Mailcode_Commands_Command $command |
|
| 55 | - * @throws Mailcode_Translator_Exception |
|
| 56 | - * @return string |
|
| 57 | - */ |
|
| 51 | + /** |
|
| 52 | + * Translates a single command to the target syntax. |
|
| 53 | + * |
|
| 54 | + * @param Mailcode_Commands_Command $command |
|
| 55 | + * @throws Mailcode_Translator_Exception |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 58 | 58 | public function translateCommand(Mailcode_Commands_Command $command) : string |
| 59 | 59 | { |
| 60 | 60 | return $this->createTranslator($command)->translate($command); |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | public function createTranslator(Mailcode_Commands_Command $command) : BaseCommandTranslation |
| 69 | 69 | { |
| 70 | 70 | $class = sprintf( |
| 71 | - __CLASS__ .'\%s\%sTranslation', |
|
| 71 | + __CLASS__.'\%s\%sTranslation', |
|
| 72 | 72 | $this->getTypeID(), |
| 73 | 73 | $command->getID() |
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | - if(!class_exists($class)) |
|
| 76 | + if (!class_exists($class)) |
|
| 77 | 77 | { |
| 78 | 78 | throw new Mailcode_Translator_Exception( |
| 79 | 79 | sprintf('Unknown command %s in translator', $command->getID()), |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $translator = new $class($command); |
| 89 | 89 | |
| 90 | - if($translator instanceof BaseCommandTranslation) |
|
| 90 | + if ($translator instanceof BaseCommandTranslation) |
|
| 91 | 91 | { |
| 92 | 92 | return $translator; |
| 93 | 93 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $subject = $safeguard->makeSafe(); |
| 117 | 117 | |
| 118 | - if(!$safeguard->hasPlaceholders()) |
|
| 118 | + if (!$safeguard->hasPlaceholders()) |
|
| 119 | 119 | { |
| 120 | 120 | return $subject; |
| 121 | 121 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $replaces = array(); |
| 126 | 126 | |
| 127 | - foreach($placeholders as $placeholder) |
|
| 127 | + foreach ($placeholders as $placeholder) |
|
| 128 | 128 | { |
| 129 | 129 | $command = $placeholder->getCommand(); |
| 130 | 130 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * @param bool $enabled |
| 34 | 34 | * @return $this |
| 35 | 35 | */ |
| 36 | - public function setIDNDecoding(bool $enabled=true) : self |
|
| 36 | + public function setIDNDecoding(bool $enabled = true) : self |
|
| 37 | 37 | { |
| 38 | 38 | return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_IDN_DECODE, $enabled); |
| 39 | 39 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * @param bool $enabled |
| 34 | 34 | * @return $this |
| 35 | 35 | */ |
| 36 | - public function setIDNEncoding(bool $enabled=true) : self |
|
| 36 | + public function setIDNEncoding(bool $enabled = true) : self |
|
| 37 | 37 | { |
| 38 | 38 | return $this->setEncodingEnabled(Mailcode_Commands_Keywords::TYPE_IDN_ENCODE, $enabled); |
| 39 | 39 | } |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | ->getInfo() |
| 35 | 35 | ->getTokenByParamName(DecryptInterface::PARAMETER_NAME); |
| 36 | 36 | |
| 37 | - if($token === null) { |
|
| 37 | + if ($token === null) { |
|
| 38 | 38 | return; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | if (!$token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) { |
| 42 | 42 | $this->validationResult->makeError( |
| 43 | - t('Invalid decryption key token:') . ' ' . t('Expected a string.'), |
|
| 43 | + t('Invalid decryption key token:').' '.t('Expected a string.'), |
|
| 44 | 44 | DecryptInterface::VALIDATION_DECRYPT_CODE_WRONG_TYPE |
| 45 | 45 | ); |
| 46 | 46 | return; |
@@ -57,20 +57,20 @@ discard block |
||
| 57 | 57 | public function getDecryptionKeyName() : string |
| 58 | 58 | { |
| 59 | 59 | $key = $this->getDecryptionKeyToken(); |
| 60 | - if($key === null) { |
|
| 60 | + if ($key === null) { |
|
| 61 | 61 | return ''; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $keyName = $key->getText(); |
| 65 | 65 | |
| 66 | - if(empty($keyName)) { |
|
| 66 | + if (empty($keyName)) { |
|
| 67 | 67 | $keyName = (string)DecryptSettings::getDefaultKeyName(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return $keyName; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function enableDecryption(string $keyName=DecryptInterface::DEFAULT_DECRYPTION_KEY_NAME) : self |
|
| 73 | + public function enableDecryption(string $keyName = DecryptInterface::DEFAULT_DECRYPTION_KEY_NAME) : self |
|
| 74 | 74 | { |
| 75 | 75 | $this->decryptionKeyToken = $this |
| 76 | 76 | ->requireParams() |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | public function disableDecryption() : self |
| 84 | 84 | { |
| 85 | - if(isset($this->decryptionKeyToken)) { |
|
| 85 | + if (isset($this->decryptionKeyToken)) { |
|
| 86 | 86 | $this |
| 87 | 87 | ->requireParams() |
| 88 | 88 | ->getInfo() |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | declare(strict_types=1); |
| 14 | 14 | |
| 15 | -use AppUtils\ConvertHelper\JSONConverter;use AppUtils\CSVHelper; |
|
| 16 | -use AppUtils\CSVHelper_Exception;use AppUtils\FileHelper; |
|
| 17 | -use AppUtils\FileHelper_Exception;use libphonenumber\PhoneNumberFormat; |
|
| 18 | -use libphonenumber\PhoneNumberUtil;use Mailcode\Mailcode;use function AppLocalize\pts; |
|
| 15 | +use AppUtils\ConvertHelper\JSONConverter; use AppUtils\CSVHelper; |
|
| 16 | +use AppUtils\CSVHelper_Exception; use AppUtils\FileHelper; |
|
| 17 | +use AppUtils\FileHelper_Exception; use libphonenumber\PhoneNumberFormat; |
|
| 18 | +use libphonenumber\PhoneNumberUtil; use Mailcode\Mailcode; use function AppLocalize\pts; |
|
| 19 | 19 | |
| 20 | 20 | require_once 'prepend.php'; |
| 21 | 21 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $meta = $phoneNumberUtil->getMetadataForRegion($code); |
| 96 | 96 | if (!$meta) { |
| 97 | - die('No metadata for ' . $code); |
|
| 97 | + die('No metadata for '.$code); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $exampleNumber = $phoneNumberUtil->getExampleNumber($code); |
| 101 | - if(empty($exampleNumber)) { |
|
| 102 | - die('No example number for ' . $code); |
|
| 101 | + if (empty($exampleNumber)) { |
|
| 102 | + die('No example number for '.$code); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $local = $phoneNumberUtil->formatInOriginalFormat($exampleNumber, $code); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | // IF type. |
| 45 | 45 | $method = 'translate'.$this->getIfType($command); |
| 46 | 46 | |
| 47 | - if(method_exists($this, $method)) |
|
| 47 | + if (method_exists($this, $method)) |
|
| 48 | 48 | { |
| 49 | 49 | return (string)$this->$method($command); |
| 50 | 50 | } |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $keywords = $command->getLogicKeywords()->getKeywords(); |
| 66 | 66 | |
| 67 | - foreach($keywords as $keyword) |
|
| 67 | + foreach ($keywords as $keyword) |
|
| 68 | 68 | { |
| 69 | 69 | $keyCommand = $keyword->getCommand(); |
| 70 | 70 | |
| 71 | - if($keyCommand instanceof Mailcode_Commands_IfBase) |
|
| 71 | + if ($keyCommand instanceof Mailcode_Commands_IfBase) |
|
| 72 | 72 | { |
| 73 | 73 | $body .= ' '.$this->getSign($keyword).' '.$this->translateBody($keyCommand); |
| 74 | 74 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | protected function getSign(Mailcode_Commands_LogicKeywords_Keyword $keyword) : string |
| 98 | 98 | { |
| 99 | - switch($keyword->getName()) |
|
| 99 | + switch ($keyword->getName()) |
|
| 100 | 100 | { |
| 101 | 101 | case 'and': |
| 102 | 102 | return 'and'; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | $sign = '!'; |
| 131 | 131 | |
| 132 | - if($notEmpty) |
|
| 132 | + if ($notEmpty) |
|
| 133 | 133 | { |
| 134 | 134 | $sign = ''; |
| 135 | 135 | } |
@@ -145,12 +145,12 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $params = $command->getParams(); |
| 147 | 147 | |
| 148 | - if(!$params) |
|
| 148 | + if (!$params) |
|
| 149 | 149 | { |
| 150 | 150 | return ''; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if($command->hasFreeformParameters()) |
|
| 153 | + if ($command->hasFreeformParameters()) |
|
| 154 | 154 | { |
| 155 | 155 | return $params->getStatementString(); |
| 156 | 156 | } |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | return $params->getNormalized(); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - protected function _translateVariable(Mailcode_Variables_Variable $variable, string $comparator, string $value, bool $insensitive=false) : string |
|
| 161 | + protected function _translateVariable(Mailcode_Variables_Variable $variable, string $comparator, string $value, bool $insensitive = false) : string |
|
| 162 | 162 | { |
| 163 | - $fullName = $this->formatVariableName($variable->getFullName()); |
|
| 163 | + $fullName = $this->formatVariableName($variable->getFullName()); |
|
| 164 | 164 | |
| 165 | - if($insensitive) |
|
| 165 | + if ($insensitive) |
|
| 166 | 166 | { |
| 167 | 167 | $fullName .= '|lower'; |
| 168 | 168 | $value = mb_strtolower($value); |
@@ -40,8 +40,7 @@ |
||
| 40 | 40 | if($keyCommand instanceof Mailcode_Commands_IfBase) |
| 41 | 41 | { |
| 42 | 42 | $body .= ' '.$this->getSign($keyword).' '.$this->translateBody($keyCommand); |
| 43 | - } |
|
| 44 | - else |
|
| 43 | + } else |
|
| 45 | 44 | { |
| 46 | 45 | throw new Mailcode_Exception( |
| 47 | 46 | 'Keyword command type does not match expected base class.', |