fix: 🚨 resolve phpcs errors
This commit is contained in:
parent
664dd850a2
commit
a7d7436b10
11 changed files with 29 additions and 35 deletions
|
|
@ -27,8 +27,7 @@
|
|||
<rule ref="Generic.Files.LineLength"/>
|
||||
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
|
||||
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
|
||||
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
|
||||
<rule ref="Generic.Functions.CallTimePassByReference"/>
|
||||
<rule ref="Generic.Formatting.SpaceAfterCast"/>
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
||||
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
|
||||
<rule ref="Generic.Metrics.NestingLevel"/>
|
||||
|
|
@ -42,9 +41,7 @@
|
|||
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
|
||||
<rule ref="MySource.PHP.EvalObjectFactory"/>
|
||||
<rule ref="MySource.PHP.GetRequestData"/>
|
||||
<rule ref="MySource.PHP.AjaxNullComparison"/>
|
||||
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
|
||||
<rule ref="PEAR.Classes.ClassDeclaration"/>
|
||||
<rule ref="PEAR.Commenting.InlineComment"/>
|
||||
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
||||
|
|
@ -77,7 +74,6 @@
|
|||
<rule ref="Squiz.Scope.MemberVarScope"/>
|
||||
<rule ref="Squiz.Scope.MethodScope"/>
|
||||
<rule ref="Squiz.Scope.StaticThisUsage"/>
|
||||
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
|
||||
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
|
||||
<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
|
||||
<properties>
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ class ApiErrorException extends \RuntimeException
|
|||
* Create a new exception base on ApiError enum.
|
||||
*
|
||||
* @param \LDC\LDCCRM\Enums\ApiError $error
|
||||
* @param integer $httpCode
|
||||
* @param string $message
|
||||
* @param \Throwable|null $previous
|
||||
* @param integer $httpCode
|
||||
* @param string $message
|
||||
* @param \Throwable|null $previous
|
||||
*/
|
||||
public function __construct(ApiError $error, int $httpCode = 400, string $message = '', \Throwable $previous = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -327,11 +327,11 @@ class ArcadiaMailDefault extends ClientModel
|
|||
try {
|
||||
$properties['state_order'] = (\is_object($properties['state_order']) and
|
||||
get_class($properties['state_order']) === ArcadiaOrderType::class) ?
|
||||
$properties['state_order']->value() : (ctype_digit((string)$properties['state_order']) ?
|
||||
(int)$properties['state_order'] : $properties['state_order']);
|
||||
$properties['state_order']->value() : (ctype_digit((string) $properties['state_order']) ?
|
||||
(int) $properties['state_order'] : $properties['state_order']);
|
||||
} catch (\TypeError | \BadMethodCallException) {
|
||||
// * Cast anyway
|
||||
$properties['state_order'] = (int)$properties['state_order'];
|
||||
$properties['state_order'] = (int) $properties['state_order'];
|
||||
}
|
||||
}
|
||||
parent::fill($properties);
|
||||
|
|
|
|||
|
|
@ -296,11 +296,11 @@ class ArcadiaMailGame extends ClientModel
|
|||
try {
|
||||
$properties['state_order'] = (\is_object($properties['state_order']) and
|
||||
get_class($properties['state_order']) === ArcadiaOrderType::class) ?
|
||||
$properties['state_order']->value : (ctype_digit((string)$properties['state_order']) ?
|
||||
(int)$properties['state_order'] : $properties['state_order']);
|
||||
$properties['state_order']->value : (ctype_digit((string) $properties['state_order']) ?
|
||||
(int) $properties['state_order'] : $properties['state_order']);
|
||||
} catch (\TypeError | \BadMethodCallException) {
|
||||
// * Cast anyway
|
||||
$properties['state_order'] = (int)$properties['state_order'];
|
||||
$properties['state_order'] = (int) $properties['state_order'];
|
||||
}
|
||||
}
|
||||
parent::fill($properties);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ abstract class ClientModel implements \JsonSerializable
|
|||
$type = $this->getPropType($field);
|
||||
// * Force boolean
|
||||
if ($type === 'bool') {
|
||||
$value = (\is_int($value) and ($value === 1 or $value === 0)) ? (bool)$value : $value;
|
||||
$value = (\is_int($value) and ($value === 1 or $value === 0)) ? (bool) $value : $value;
|
||||
}
|
||||
if (!is_null($value) and !$this->checkFieldType($type, $value)) {
|
||||
throw new ValidationException("Wrong type for $field");
|
||||
|
|
@ -270,7 +270,7 @@ abstract class ClientModel implements \JsonSerializable
|
|||
case '\\' . ArcadiaOrderType::class:
|
||||
return $checkValueIsEnum(\ltrim($type, '\\'), $value);
|
||||
case 'boolean':
|
||||
return \is_bool(\is_int($value) ? (bool)$value : $value);
|
||||
return \is_bool(\is_int($value) ? (bool) $value : $value);
|
||||
case 'array':
|
||||
return \is_array($value);
|
||||
case 'string':
|
||||
|
|
|
|||
|
|
@ -356,10 +356,10 @@ class Customer extends ClientModel
|
|||
$properties['country'] = (\is_object($properties['country']) and
|
||||
get_class($properties['country']) === Country::class) ?
|
||||
$properties['country']->value : (is_numeric(trim($properties['country'])) ?
|
||||
(int)$properties['country'] : $properties['country']);
|
||||
(int) $properties['country'] : $properties['country']);
|
||||
} catch (TypeError | \BadMethodCallException $e) {
|
||||
// * Cast anyway
|
||||
$properties['country'] = (int)$properties['country'];
|
||||
$properties['country'] = (int) $properties['country'];
|
||||
}
|
||||
}
|
||||
parent::fill($properties);
|
||||
|
|
|
|||
|
|
@ -154,11 +154,11 @@ class Question extends ClientModel
|
|||
try {
|
||||
$properties['type'] = (\is_object($properties['type']) and
|
||||
get_class($properties['type']) === QuestionType::class) ?
|
||||
$properties['type']->value : (ctype_digit((string)$properties['type']) ?
|
||||
(int)$properties['type'] : $properties['type']);
|
||||
$properties['type']->value : (ctype_digit((string) $properties['type']) ?
|
||||
(int) $properties['type'] : $properties['type']);
|
||||
} catch (\TypeError | \BadMethodCallException) {
|
||||
// * Cast anyway
|
||||
$properties['type'] = (int)$properties['type'];
|
||||
$properties['type'] = (int) $properties['type'];
|
||||
}
|
||||
}
|
||||
parent::fill($properties);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ trait BaseEnum
|
|||
}
|
||||
$baseArray[$index] = $elements[$enum->name];
|
||||
}
|
||||
$array = array_merge($array, [$enum->name => (object)$baseArray]);
|
||||
$array = array_merge($array, [$enum->name => (object) $baseArray]);
|
||||
}, self::cases());
|
||||
self::setCache('enums', $array);
|
||||
} //end if
|
||||
|
|
@ -124,7 +124,7 @@ trait BaseEnum
|
|||
* Fetch enum using value.
|
||||
*
|
||||
* @param \LDC\LDCCRM\Traits\BaseEnum|integer|string $value
|
||||
* @param string $field
|
||||
* @param string $field
|
||||
* @return \LDC\LDCCRM\Traits\BaseEnum|null
|
||||
*/
|
||||
public static function make(self|int|string $value, string $field = 'value'): self|null
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class Response
|
|||
// * Body should be json data.
|
||||
if (($decodedJson = $this->tryDecodeJson($this->body->getContents())) === false) {
|
||||
if (Utils::getConfig('app.env') === 'testing') {
|
||||
dump((string)$this->body);
|
||||
dump((string) $this->body);
|
||||
}
|
||||
throw new CrmException('The Api should have returned JSON data');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ class Utils
|
|||
),
|
||||
'validate' => function () use ($value, $params) {
|
||||
if (\is_string($value)) {
|
||||
return \strlen($value) === (int)$params[0];
|
||||
return \strlen($value) === (int) $params[0];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -307,10 +307,10 @@ class Utils
|
|||
),
|
||||
'validate' => function () use ($value, $params) {
|
||||
if (\is_string($value)) {
|
||||
return \strlen($value) >= (int)$params[0];
|
||||
return \strlen($value) >= (int) $params[0];
|
||||
}
|
||||
if (\is_int($value)) {
|
||||
return $value >= (int)$params[0];
|
||||
return $value >= (int) $params[0];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -337,10 +337,10 @@ class Utils
|
|||
),
|
||||
'validate' => function () use ($value, $params) {
|
||||
if (\is_string($value)) {
|
||||
return \strlen($value) <= (int)$params[0];
|
||||
return \strlen($value) <= (int) $params[0];
|
||||
}
|
||||
if (\is_int($value)) {
|
||||
return $value <= (int)$params[0];
|
||||
return $value <= (int) $params[0];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -569,10 +569,10 @@ class Utils
|
|||
): Request {
|
||||
// Convert bool to integer.
|
||||
$query = \array_map(function ($v) {
|
||||
return is_bool($v) ? (int)$v : $v;
|
||||
return is_bool($v) ? (int) $v : $v;
|
||||
}, $query);
|
||||
$data = \array_map(function ($v) {
|
||||
return is_bool($v) ? (int)$v : $v;
|
||||
return is_bool($v) ? (int) $v : $v;
|
||||
}, $data);
|
||||
|
||||
$routes = \json_decode(\file_get_contents(__DIR__ . '/routes.json'), true);
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class WPCrm
|
|||
public static function check()
|
||||
{
|
||||
self::bootSessionIfNeeded();
|
||||
return (bool)self::getUser();
|
||||
return (bool) self::getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -307,8 +307,6 @@ class WPCrm
|
|||
* Activate the current user
|
||||
*
|
||||
* @return boolean True if the operation succeeded.
|
||||
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a customer's hashcode could not be validated.
|
||||
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
||||
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
||||
* Possibles are : - modelNotFound, If this customer hashcode could not be found.
|
||||
* - customerAlreadyActive, It the customer is already activated.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue