Missing class import via use statement (line '115', column '9'). Open
(new \App\YetiForce\Register())->recreate();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '116', column '14'). Open
throw new \App\Exceptions\AppException('ERR_RECREATE_APP_ACCESS');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '160', column '18'). Open
$reflect = new \ReflectionClass($this);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid assigning values to variables in if clauses and the like (line '163', column '53'). Open
private function getData(): array
{
$data = [
'appId' => Register::getInstanceKey()
];
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\Settings_Companies_Record_Model' in method 'postProcess'. Open
$recordModel = \Settings_Companies_Record_Model::getInstance();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\YetiForce\Register' in method 'getData'. Open
'appId' => Register::getInstanceKey()
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
syntax error, unexpected '?', expecting function (T_FUNCTION) or const (T_CONST)
Open
protected ?string $error;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private const TYPES = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Type */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const URL = 'https://api.yetiforce.eu/emails';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool Response result */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string URL */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Process identificator - register */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Endpoints */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string|null Last eroor */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string E-mail address */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const PROCESS_REGISTER = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected ?string $error;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::PROCESS_INIT => 'POST',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::PROCESS_REGISTER => 'PUT'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Process identificator - init */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (409 === $client->getStatusCode() && false !== stripos($this->error, 'app')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->success = 204 === $client->getStatusCode();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Settings_Companies_Record_Model::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const PROCESS_INIT = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool Newsletter agreement */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Code */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $email
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->getUITypeModel()->validate($this->email, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected int $type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->success && self::PROCESS_REGISTER === $this->type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getData(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data[$property->getName()] = $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set code.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function send(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $type Types {@see self::TYPES}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setType(int $type): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = self::TYPES[$this->type];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->error ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$reflect = new \ReflectionClass($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($property->isInitialized($this) && null !== ($value = $property->getValue($this))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private string $email;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$client = new ApiClient();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setEmail(string $email): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->error = $client->getError();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\YetiForce\Register())->recreate();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldName = 'email';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $recordModel->getFieldInstanceByName($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set($fieldName, $fieldModel->getDBValue($this->email));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Request sending an email with a verification token.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'appId' => Register::getInstanceKey()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected bool $success;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('ERR_RECREATE_APP_ACCESS');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function postProcess(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get data for request.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($reflect->getProperties(\ReflectionProperty::IS_PRIVATE) as $property) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set e-mail address.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setCode(string $code): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$property->setAccessible(true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private bool $newsletter;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setNewsletter(bool $newsletter): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->token = $code;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->success = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private string $token;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getError(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->email = $email;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set newsletter agreement.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->newsletter = $newsletter;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$client->send(self::URL, $type, ['form_params' => $this->getData()]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $newsletter
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $code
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get last error.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Post processes.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set type request.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->type = $type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks