YetiForceCompany/YetiForceCRM

View on GitHub
app/YetiForce/EmailVerification.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '115', column '9').
Open

            (new \App\YetiForce\Register())->recreate();
Severity: Minor
Found in app/YetiForce/EmailVerification.php by phpmd

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');
Severity: Minor
Found in app/YetiForce/EmailVerification.php by phpmd

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);
Severity: Minor
Found in app/YetiForce/EmailVerification.php by phpmd

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()
        ];
Severity: Minor
Found in app/YetiForce/EmailVerification.php by phpmd

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();
Severity: Minor
Found in app/YetiForce/EmailVerification.php by phpmd

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()
Severity: Minor
Found in app/YetiForce/EmailVerification.php by phpmd

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;
Severity: Critical
Found in app/YetiForce/EmailVerification.php by phan

Spaces must be used to indent lines; tabs are not allowed
Open

    private const TYPES = [

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var int Type */

Spaces must be used to indent lines; tabs are not allowed
Open

    public const URL = 'https://api.yetiforce.eu/emails';

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var bool Response result */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string URL */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** Process identificator - register */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string Endpoints */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string|null Last eroor */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string E-mail address */

Spaces must be used to indent lines; tabs are not allowed
Open

    public const PROCESS_REGISTER = 1;

Spaces must be used to indent lines; tabs are not allowed
Open

    protected ?string $error;

Spaces must be used to indent lines; tabs are not allowed
Open

        self::PROCESS_INIT => 'POST',

Spaces must be used to indent lines; tabs are not allowed
Open

        self::PROCESS_REGISTER => 'PUT'

Spaces must be used to indent lines; tabs are not allowed
Open

    ];

Spaces must be used to indent lines; tabs are not allowed
Open

    /** Process identificator - init */

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

        if (409 === $client->getStatusCode() && false !== stripos($this->error, 'app')) {

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->success = 204 === $client->getStatusCode();

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $recordModel = \Settings_Companies_Record_Model::getInstance();

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        return $data;

Spaces must be used to indent lines; tabs are not allowed
Open

    public const PROCESS_INIT = 0;

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var bool Newsletter agreement */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string Code */

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $email

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;

Spaces must be used to indent lines; tabs are not allowed
Open

            $fieldModel->getUITypeModel()->validate($this->email, true);

Spaces must be used to indent lines; tabs are not allowed
Open

    protected int $type;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return self

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($this->success && self::PROCESS_REGISTER === $this->type) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $recordModel->save();

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

    private function getData(): array

Spaces must be used to indent lines; tabs are not allowed
Open

                $data[$property->getName()] = $value;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Set code.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return self

Spaces must be used to indent lines; tabs are not allowed
Open

    public function send(): bool

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $type Types {@see self::TYPES}

Spaces must be used to indent lines; tabs are not allowed
Open

    public function setType(int $type): self

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $type = self::TYPES[$this->type];

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->error ?? '';

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        $reflect = new \ReflectionClass($this);

Spaces must be used to indent lines; tabs are not allowed
Open

            if ($property->isInitialized($this) && null !== ($value = $property->getValue($this))) {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    private string $email;

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $client = new ApiClient();

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public function setEmail(string $email): self

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->error = $client->getError();

Spaces must be used to indent lines; tabs are not allowed
Open

            (new \App\YetiForce\Register())->recreate();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            $fieldName = 'email';

Spaces must be used to indent lines; tabs are not allowed
Open

            $fieldModel = $recordModel->getFieldInstanceByName($fieldName);

Spaces must be used to indent lines; tabs are not allowed
Open

            $recordModel->set($fieldName, $fieldModel->getDBValue($this->email));

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Request sending an email with a verification token.

Spaces must be used to indent lines; tabs are not allowed
Open

        $data = [

Spaces must be used to indent lines; tabs are not allowed
Open

            'appId' => Register::getInstanceKey()

Spaces must be used to indent lines; tabs are not allowed
Open

    protected bool $success;

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            throw new \App\Exceptions\AppException('ERR_RECREATE_APP_ACCESS');

Spaces must be used to indent lines; tabs are not allowed
Open

    public function postProcess(): void

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get data for request.

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($reflect->getProperties(\ReflectionProperty::IS_PRIVATE) as $property) {

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * Set e-mail address.

Spaces must be used to indent lines; tabs are not allowed
Open

    public function setCode(string $code): self

Spaces must be used to indent lines; tabs are not allowed
Open

            $property->setAccessible(true);

Spaces must be used to indent lines; tabs are not allowed
Open

    private bool $newsletter;

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public function setNewsletter(bool $newsletter): self

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return self

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->token = $code;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->success = false;

Spaces must be used to indent lines; tabs are not allowed
Open

    private string $token;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return $this

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getError(): string

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return void

Spaces must be used to indent lines; tabs are not allowed
Open

        ];

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->email = $email;

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this;

Spaces must be used to indent lines; tabs are not allowed
Open

     * Set newsletter agreement.

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->newsletter = $newsletter;

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $client->send(self::URL, $type, ['form_params' => $this->getData()]);

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool $newsletter

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $code

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get last error.

Spaces must be used to indent lines; tabs are not allowed
Open

     * Post processes.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Set type request.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->type = $type;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string

Spaces must be used to indent lines; tabs are not allowed
Open

    {

There are no issues that match your filters.

Category
Status