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)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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;
- 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 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open
private string $id;
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
private string $id;
- Read upRead up
- Exclude checks
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;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->id = $data['id'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->paymentFrequency = $data['paymentFrequency'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Payment frequency. */
- 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->max = $data['packageType']['maxUsers'] ?? 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private int $max = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Construct.
- 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 $currencyCode;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->priceNet = (int) ($data['priceNet'] ?? 0) / 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private string $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Price net. */
- 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
'yearly' => 'Y',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->currencyCode = $data['currencyCode'] ?? '';
- 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
/** @var int[] User Terms. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $data
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct(array $data)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'monthly' => 'M',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Package ID */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private string $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $priceNet;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Currency code */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->name = $data['packageType']['name'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Name. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var float Price gross. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->priceGross = (int) ($data['priceGross'] ?? 0) / 100;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getName(): 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
* Get net price
- 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 gross price
- 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->label;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCurrencyCode(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->currencyCode;
- 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
private $priceGross;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->name = $data['packageType']['name'] ?? '';
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get currency Code
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $format ? number_format($this->priceNet, 2, '.', '') : $this->priceNet;
- 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
* Get short name payment frequency
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::PAYMENT_FREQ_MAP[$value] ?? $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
}
- 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 const PAYMENT_FREQ_MAP = [
- 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
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
Spaces must be used to indent lines; tabs are not allowed Open
* Get name.
- 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
Spaces must be used to indent lines; tabs are not allowed Open
* Get payment frequency
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPaymentFrequency(): 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
*/
- 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->paymentFrequency;
- 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 int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $format
- 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
public function getPaymentFrequencyShort(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPrice(): int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->getPriceNet();
- 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 !$this->max || \App\User::getNumberOfUsers() <= $this->max;
- 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
* Get full name for payment frequency
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get package ID.
- 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
/** @var string Label. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private ?string $paymentFrequency;
- 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->label = $data['packageType']['label'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int|float|string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if package is available.
- 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
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 price.
- 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->name;
- 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
return 'LBL_SHOP_PAYMENT_FREQUENCY_' . $this->getPaymentFrequencyShort();
- 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
public function getLabel(): ?string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $this->getPaymentFrequency();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPaymentFrequencyLabel(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isAvailable(): 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int|float|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
*
- 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
return $this->id;
- 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 getPriceGross(bool $format = false)
- 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
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 $format ? number_format($this->priceGross, 2, '.', '') : $this->priceGross;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get label.
- 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 getId(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPriceNet(bool $format = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks