YetiForceCompany/YetiForceCRM

View on GitHub
app/YetiForce/Shop/Package.php

Summary

Maintainability
A
0 mins
Test Coverage

The method getPriceGross has a boolean flag argument $format, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getPriceGross(bool $format = false)
Severity: Minor
Found in app/YetiForce/Shop/Package.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method getPriceNet has a boolean flag argument $format, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getPriceNet(bool $format = false)
Severity: Minor
Found in app/YetiForce/Shop/Package.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid using static access to class '\App\User' in method 'isAvailable'.
Open

        return !$this->max || \App\User::getNumberOfUsers() <= $this->max;
Severity: Minor
Found in app/YetiForce/Shop/Package.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 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open

    private string $id;
Severity: Critical
Found in app/YetiForce/Shop/Package.php by phan

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    private string $id;
Severity: Minor
Found in app/YetiForce/Shop/Package.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

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

    private ?string $label;

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

        $this->id = $data['id'] ?? '';

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

        $this->paymentFrequency = $data['paymentFrequency'] ?? '';

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

    /** @var string Payment frequency. */

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->max = $data['packageType']['maxUsers'] ?? 0;

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

    private int $max = 0;

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

     * Construct.

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 $currencyCode;

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

        $this->priceNet = (int) ($data['priceNet'] ?? 0) / 100;

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

    private string $id;

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

    /** @var int Price net. */

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

     *

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

        'yearly' => 'Y',

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

        $this->currencyCode = $data['currencyCode'] ?? '';

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

    }

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

    /** @var int[] User Terms. */

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

     * @param array $data

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

    public function __construct(array $data)

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

        'monthly' => 'M',

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

    /** @var string Package ID */

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

    private string $name;

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

    private $priceNet;

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

    /** @var string Currency code */

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

        $this->name = $data['packageType']['name'] ?? '';

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

    /** @var string Name. */

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

    /** @var float Price gross. */

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

        $this->priceGross = (int) ($data['priceGross'] ?? 0) / 100;

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

    public function getName(): 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

     * Get net price

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 gross price

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->label;

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

    public function getCurrencyCode(): string

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

        return $this->currencyCode;

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

    private $priceGross;

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

        $this->name = $data['packageType']['name'] ?? '';

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

     */

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

     * Get currency Code

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

        return $format ? number_format($this->priceNet, 2, '.', '') : $this->priceNet;

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

     * Get short name payment frequency

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

        return self::PAYMENT_FREQ_MAP[$value] ?? $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

    }

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 const PAYMENT_FREQ_MAP = [

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

    }

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

    /**

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

     * Get name.

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

    /**

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

     * Get payment frequency

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

    public function getPaymentFrequency(): 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

     */

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->paymentFrequency;

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 int

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

     * @param bool $format

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

    public function getPaymentFrequencyShort(): string

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

    public function getPrice(): int

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

        return $this->getPriceNet();

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 !$this->max || \App\User::getNumberOfUsers() <= $this->max;

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

     * Get full name for payment frequency

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

     * Get package ID.

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

    /** @var string Label. */

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

    private ?string $paymentFrequency;

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->label = $data['packageType']['label'] ?? '';

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

     * @param bool $format

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

     * @return int|float|string

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

     * Check if package is available.

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

    {

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 price.

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->name;

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

        return 'LBL_SHOP_PAYMENT_FREQUENCY_' . $this->getPaymentFrequencyShort();

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

    public function getLabel(): ?string

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

        $value = $this->getPaymentFrequency();

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

    public function getPaymentFrequencyLabel(): string

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

    public function isAvailable(): 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

    }

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

     * @return int|float|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

     *

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

        return $this->id;

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 getPriceGross(bool $format = false)

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

    {

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 $format ? number_format($this->priceGross, 2, '.', '') : $this->priceGross;

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

     * Get label.

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 getId(): string

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

    public function getPriceNet(bool $format = false)

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

    /**

There are no issues that match your filters.

Category
Status