AbstractBaseProduct
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class AbstractBaseProduct
{
private const DEFAULT_CURRENCY = 'EUR';
/**
Method fromArray
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromArray(array $data)
{
$name = $data['name'] ?? '';
$self = new static($name);
$self->label = \App\Purifier::purifyByType($data['label'] ?? '', \App\Purifier::TEXT);
Function fromArray
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function fromArray(array $data)
{
$name = $data['name'] ?? '';
$self = new static($name);
$self->label = \App\Purifier::purifyByType($data['label'] ?? '', \App\Purifier::TEXT);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Missing class import via use statement (line '133', column '59'). Open
$this->expirationDate = (new \DateTime($expiresAt, new \DateTimeZone('GMT')))->setTimezone(new \DateTimeZone(\App\Fields\DateTime::getTimeZone()))->format('Y-m-d');
- 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
The method getAlertMessage has a boolean flag argument $require, which is a certain sign of a Single Responsibility Principle violation. Open
public function getAlertMessage(bool $require = true): string
- 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
Missing class import via use statement (line '133', column '99'). Open
$this->expirationDate = (new \DateTime($expiresAt, new \DateTimeZone('GMT')))->setTimezone(new \DateTimeZone(\App\Fields\DateTime::getTimeZone()))->format('Y-m-d');
- 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 '133', column '33'). Open
$this->expirationDate = (new \DateTime($expiresAt, new \DateTimeZone('GMT')))->setTimezone(new \DateTimeZone(\App\Fields\DateTime::getTimeZone()))->format('Y-m-d');
- 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 using static access to class '\App\Purifier' in method 'fromArray'. Open
$self->label = \App\Purifier::purifyByType($data['label'] ?? '', \App\Purifier::TEXT);
- 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
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->expirationDate = null;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\YetiForce\Shop' in method 'getVariable'. Open
], \App\YetiForce\Shop::getVariablePayments());
- 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 '__construct'. Open
$statusData = \App\YetiForce\Register::getProduct($productName);
- 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\Purifier' in method 'fromArray'. Open
$self->introduction = \App\Purifier::purifyByType($data['shortDescription'] ?? '', \App\Purifier::TEXT);
- 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\Purifier' in method 'fromArray'. Open
$self->description = \App\Purifier::decodeHtml(\App\Purifier::purifyByType($data['description'] ?? '', \App\Purifier::HTML));
- 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\Fields\DateTime' in method '__construct'. Open
$this->expirationDate = (new \DateTime($expiresAt, new \DateTimeZone('GMT')))->setTimezone(new \DateTimeZone(\App\Fields\DateTime::getTimeZone()))->format('Y-m-d');
- 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\Purifier' in method 'fromArray'. Open
$self->description = \App\Purifier::decodeHtml(\App\Purifier::purifyByType($data['description'] ?? '', \App\Purifier::HTML));
- 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\Fields\Currency' in method 'fromArray'. Open
}
- 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
protected string $id;
- Exclude checks
Avoid variables with short names like $a. Configured minimum length is 3. Open
usort($packages, fn ($a, $b) => $a->getPriceNet() <=> $b->getPriceNet());
- 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
Avoid variables with short names like $id. Configured minimum length is 3. Open
protected 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
Avoid variables with short names like $b. Configured minimum length is 3. Open
usort($packages, fn ($a, $b) => $a->getPriceNet() <=> $b->getPriceNet());
- 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
The 'getStatus()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public function getStatus(): bool
{
return $this->status;
}
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
Spaces must be used to indent lines; tabs are not allowed Open
* Product 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
/**
- 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
* Is the product featured.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var Package
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var 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
* Product 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
* Product 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
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Price packages.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Is the product active.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected string $category;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected string $website;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Fit package.
- 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
protected string $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
* Product website.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected array $packages = [];
- 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
protected string $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var 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
* @var bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Product category.
- 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
* @var 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
protected bool $active;
- 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 DEFAULT_CURRENCY = 'EUR';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var 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
* @var 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
protected bool $featured;
- 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
* Expiration date.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected string $description;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Image.
- 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
protected bool $disabled = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool Status */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $productName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->status = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->status = strtotime($this->expirationDate) >= strtotime(date('Y-m-d'));
- 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
$self->category = $data['category'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->description = \App\Purifier::decodeHtml(\App\Purifier::purifyByType($data['description'] ?? '', \App\Purifier::HTML));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($packages[$currencyCode])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get product 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
/**
- 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
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
}
- 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 string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->expirationDate = (new \DateTime($expiresAt, new \DateTimeZone('GMT')))->setTimezone(new \DateTimeZone(\App\Fields\DateTime::getTimeZone()))->format('Y-m-d');
- 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
{
- 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
protected string $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
* @var Package[]
- 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
$currencyCode = \App\Fields\Currency::getDefault()['currency_code'];
- 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
return $this->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
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return static
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = $data['name'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self = new static($name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->introduction = \App\Purifier::purifyByType($data['shortDescription'] ?? '', \App\Purifier::TEXT);
- 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
public function isConfigured(): 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
} elseif ($packages) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->packages = current($packages);
- 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 product name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Package[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getPackages(): array
- 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 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
$self->id = $data['id'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$packages[$package->getCurrencyCode()][] = $package;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (isset($packages[self::DEFAULT_CURRENCY])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private bool $status = 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 bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function fromArray(array $data)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($data['packages'] as $packageData) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->packages = $packages[self::DEFAULT_CURRENCY];
- 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
*/
- 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
$packages = [];
- 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 category.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $package;
- 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 ($statusData) {
- 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
$expiresAt = $statusData['expiresAt'];
- 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
* Check if the product is configured correctly.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$package = new Package($packageData);
- 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
* Price packages.
- 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 array $data
- 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 string|null
- 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
protected ?string $expirationDate;
- 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 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
if ($package->isAvailable()) {
- 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 string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->category;
- 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
* Introduction / short description.
- 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
/** @var bool Disabled product */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$statusData = \App\YetiForce\Register::getProduct($productName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getStatus(): 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
* Construct.
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$self->description = \App\Purifier::decodeHtml(\App\Purifier::purifyByType($data['description'] ?? '', \App\Purifier::HTML));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->image = $data['imageUrl'] ?? '';
- 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
protected ?string $image;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 176 characters Open
$this->expirationDate = (new \DateTime($expiresAt, new \DateTimeZone('GMT')))->setTimezone(new \DateTimeZone(\App\Fields\DateTime::getTimeZone()))->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->status;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->featured = $data['featured'] ?? false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->packages = $packages[$currencyCode];
- 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
* Get product price.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected string $introduction;
- 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->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
return $this->packages;
- 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->package->getPaymentFrequency();
- 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
'currency_code' => $this->getCurrencyCode(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'os0' => $this->package->getName(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($this->isExpired()) {
- 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
* Description.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct(string $productName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->name = $productName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->expirationDate = null;
- 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 subscription status.
- 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
$self->label = \App\Purifier::purifyByType($data['label'] ?? '', \App\Purifier::TEXT);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$self->website = $data['website'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get product label.
- 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
public function getCategory(): 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 product image.
- 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
public function getPaymentFrequencyShort(): 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
$message = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Vtiger_Link_Model[]
- 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 getAdditionalButtons(): array
- 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->package;
- 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
't3' => 'M',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'p3' => 1,
- 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSwitchButton(): ?\Vtiger_Link_Model
- 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 getImage(): ?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
if ($this->disabled) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($status && !$this->isConfigured()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Analyze the configuration.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return \Vtiger_Link_Model|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->package->getCurrencyCode();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Package|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->package->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
return array_merge([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$status = $this->getStatus();
- 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 getCurrencyCode(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get fit package.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getIntroduction(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], \App\YetiForce\Shop::getVariablePayments());
- 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 getFitPackage(): ?Package
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->image ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* The period for which the service is purchased.
- 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 array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getVariable(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'on0' => 'Package',
- 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
$message = 'LBL_FUNCTIONALITY_NOT_AVAILABLE';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$message = 'LBL_SUBSCRIPTION_HAS_EXPIRED';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- 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->package->getPrice();
- 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->description;
- 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
'src' => 1,
- 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
$message = 'LBL_FUNCTIONALITY_HAS_NOT_YET_BEEN_ACTIVATED';
- 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
* Product modal additional buttons.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->expirationDate ?? null;
- 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 isActive(): 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
usort($packages, fn ($a, $b) => $a->getPriceNet() <=> $b->getPriceNet());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->introduction;
- 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
public function getAlertMessage(bool $require = true): 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|null
- 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
return isset($this->expirationDate) && !$this->status;
- 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
}
- 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
public function getDescription(): 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
'cmd' => '_xclick-subscriptions',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'no_shipping' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'no_note' => 1,
- 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
public function analyzeConfiguration(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if product is available.
- 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 product description.
- 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 variable product.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sra' => 1,
- 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 bool $require
- 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
* Check if the service is active.
- 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
*
- 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
$message = 'LBL_PAID_FUNCTIONALITY';
- 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
/**
- 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
$packages = $this->getPackages();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->package = current($packages);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get product description.
- 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 period name for which the service is purchased.
- 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
'a3' => $this->package->getPriceGross()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Show alert in marketplace.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $message;
- 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
- 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
if (!$this->package) {
- 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 isExpired(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($require && !$status) {
- 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
{
- 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
'item_name' => $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
* Switch button to activate/deactivate service.
- 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 !empty($this->getFitPackage());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get expiration date.
- 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 isAvailable(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getExpirationDate(): ?string
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->active;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Space before opening parenthesis of function call prohibited Open
usort($packages, fn ($a, $b) => $a->getPriceNet() <=> $b->getPriceNet());
- Exclude checks