Function verify
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function verify(bool $getNames = false): string
{
$names = [];
$products = \App\YetiForce\Register::getProducts();
foreach ($products ?? [] as $row) {
- 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
The class Shop has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
final class Shop extends AbstractBase
{
/** @var string URL */
public const URL = 'https://api.yetiforce.eu/store';
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '112', column '21'). Open
$interval = (new \DateTime('now', new \DateTimeZone('GMT')))->diff(new \DateTime($productDetails['expires_at'], new \DateTimeZone('GMT')));
- 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 '112', column '42'). Open
$interval = (new \DateTime('now', new \DateTimeZone('GMT')))->diff(new \DateTime($productDetails['expires_at'], new \DateTimeZone('GMT')));
- 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 '112', column '120'). Open
$interval = (new \DateTime('now', new \DateTimeZone('GMT')))->diff(new \DateTime($productDetails['expires_at'], new \DateTimeZone('GMT')));
- 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 '112', column '75'). Open
$interval = (new \DateTime('now', new \DateTimeZone('GMT')))->diff(new \DateTime($productDetails['expires_at'], new \DateTimeZone('GMT')));
- 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 verify has a boolean flag argument $getNames, which is a certain sign of a Single Responsibility Principle violation. Open
public static function verify(bool $getNames = false): 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
Avoid using static access to class '\App\Cache' in method 'checkWithMessage'. Open
return Cache::staticGet('Shop|checkWithMessage', $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\Cache' in method 'checkWithMessage'. Open
if (Cache::staticHas('Shop|checkWithMessage', $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\YetiForce\Register' in method 'getVariablePayments'. Open
'custom' => \App\YetiForce\Register::getInstanceKey() . '|' . \App\YetiForce\Register::getCrmKey(),
- 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 'getVariablePayments'. Open
'custom' => \App\YetiForce\Register::getInstanceKey() . '|' . \App\YetiForce\Register::getCrmKey(),
- 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 'checkWithMessage'. Open
$productDetails = \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\Log' in method 'load'. Open
\App\Log::error($e->getMessage(), __METHOD__);
- 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\Json' in method 'loadProduct'. Open
$this->setProducts([\App\Json::decode($client->getResponseBody())]);
- 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 'verify'. Open
$products = \App\YetiForce\Register::getProducts();
- 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\Json' in method 'load'. Open
$this->setProducts(\App\Json::decode($client->getResponseBody()));
- 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\Json' in method 'loadProduct'. Open
if (!$this->error && 200 === $client->getStatusCode() && !\App\Json::isEmpty($client->getResponseBody())) {
- 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\Json' in method 'load'. Open
if (!$this->error && 200 === $client->getStatusCode() && !\App\Json::isEmpty($client->getResponseBody())) {
- 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 assigning values to variables in if clauses and the like (line '276', column '45'). Open
private function setProducts(array $products)
{
foreach ($products as $productData) {
$name = $productData['name'] ?? '';
$className = self::getProductClass($name);
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\App\Version' in method 'load'. Open
$client->send(self::URL . '/' . \App\Version::get() . '/products', 'GET');
- 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 getProduct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
(new self())->load();
}
- 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\Cache' in method 'checkWithMessage'. Open
Cache::staticSave('Shop|checkWithMessage', $productName, [$status, $message]);
- 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\Language' in method 'verify'. Open
$names[$productName] = \App\Language::translate($productName, 'Settings::YetiForce');
- 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\Version' in method 'loadProduct'. Open
$client->send(self::URL . '/' . \App\Version::get() . "/products/{$productId}", 'GET');
- 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\Log' in method 'loadProduct'. Open
\App\Log::error($e->getMessage(), __METHOD__);
- 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 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST)
Open
public static array $productCache = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string URL */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Product categories. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Integrations' => ['label' => 'LBL_CAT_INTEGRATIONS', 'icon' => 'yfi-integration-shop'],
- Exclude checks
Spaces must 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 $product->getStatus();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function checkWithMessage(string $productName): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$status = $message = 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
}
- Exclude checks
Spaces must 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
if ($product->isExpired()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$names[$productName] = \App\Language::translate($productName, 'Settings::YetiForce');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] Premium icons. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
1 => 'yfi-premium color-red-600',
- Exclude checks
Spaces must 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 string $section
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* https://www.paypal.com/cgi-bin/webscr
- Exclude checks
Spaces must 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 implode(', ', $names);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Extensions' => ['label' => 'LBL_CAT_ADDONS', 'icon' => 'yfi-adds-on-shop'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $state
- 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 static function getVariablePayments(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$productDetails = \App\YetiForce\Register::getProduct($productName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::staticSave('Shop|checkWithMessage', $productName, [$status, $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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
2 => 'yfi-enterprise color-yellow-600',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Product instance cache.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'image_url' => 'https://public.yetiforce.com/shop/logo.png',
- Exclude checks
Spaces must 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
* Check alert to show for product.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = self::getProductClass($productName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $onlyNames
- Exclude checks
Spaces must 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 Shop\AbstractBaseProduct[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'rm' => 2,
- Exclude checks
Spaces must 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 = new $className($productName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $product->getAlertMessage();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$productCache;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'cancel_return' => \Config\Main::$site_URL . 'index.php?module=YetiForce&parent=Settings&view=Shop&status=fail',
- Exclude checks
Spaces must 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
$interval = (new \DateTime('now', new \DateTimeZone('GMT')))->diff(new \DateTime($productDetails['expires_at'], new \DateTimeZone('GMT')));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$product = new $className($productName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get paypal URL.
- Exclude checks
Spaces must 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
* Verification of product with a 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
$names[$productName] = $productName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'business' => 'paypal@yetiforce.com',
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
'cancel_return' => \Config\Main::$site_URL . 'index.php?module=YetiForce&parent=Settings&view=Shop&status=fail',
- Exclude checks
Spaces must 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
* Verification of product.
- Exclude checks
Spaces must 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 $getNames
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function verify(bool $getNames = false): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($products ?? [] as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$product = new $className($productName);
- Exclude checks
Spaces must 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 all available products.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
3 => 'yfi-partners color-grey-600',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'All' => ['label' => 'LBL_CAT_ALL', 'icon' => 'yfi-all-shop'],
- Exclude checks
Spaces must 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 (!$status) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function checkAlert(string $productName): 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
$names = [];
- Exclude checks
Spaces must 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 [
- Exclude checks
Spaces must 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
$products = \App\YetiForce\Register::getProducts();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->load();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get variable payments.
- 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
* @param string $productName
- Exclude checks
Spaces must 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 static function getPaypalUrl(): 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' => \Config\Main::$site_URL . 'index.php?module=YetiForce&parent=Settings&view=Shop&status=success',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($productDetails) {
- 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
if (!$getNames) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const PRODUCT_CATEGORIES = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get products.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $productName
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
$interval = (new \DateTime('now', new \DateTimeZone('GMT')))->diff(new \DateTime($productDetails['expires_at'], new \DateTimeZone('GMT')));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$status = $interval->invert && $interval->days > 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [$status, $message];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @todo remove or replace
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = self::getProductClass($productName);
- Exclude checks
Spaces must 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
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->error && 200 === $client->getStatusCode() && !\App\Json::isEmpty($client->getResponseBody())) {
- Exclude checks
Spaces must 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 const URL = 'https://api.yetiforce.eu/store';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const PREMIUM_ICONS = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = self::getProductClass($productName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::staticGet('Shop|checkWithMessage', $productName);
- Exclude checks
Spaces must 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
$productName = $row['product'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function load()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->success = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error($e->getMessage(), __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param 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
public static array $productCache = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty(self::$productCache)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function check(string $productName): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::staticHas('Shop|checkWithMessage', $productName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* https://www.sandbox.paypal.com/cgi-bin/webscr.
- 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
* Verify or show a message about invalid products.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->success = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Shop\AbstractBaseProduct
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
if (!empty($productData['packages']) && ($product = $className::fromArray($productData)) && $product->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
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getProducts(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'custom' => \App\YetiForce\Register::getInstanceKey() . '|' . \App\YetiForce\Register::getCrmKey(),
- Exclude checks
Spaces must 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 string $productName
- Exclude checks
Spaces must 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 'https://www.paypal.com/cgi-bin/webscr';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$client = new ApiClient();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = self::getProductClass($name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$productCache = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->error && 200 === $client->getStatusCode() && !\App\Json::isEmpty($client->getResponseBody())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->error = $client->getError();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!class_exists($className)) {
- Exclude checks
Spaces must 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 string $productId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static function getProductClass(string $name): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set Products to cache.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$client->send(self::URL . '/' . \App\Version::get() . '/products', 'GET');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->error = $e->getMessage();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get products.
- Exclude checks
Spaces must 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 class.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($products as $productData) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($productData['packages']) && ($product = $className::fromArray($productData)) && $product->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
$this->success = 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new self())->loadProduct($productId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = $productData['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
$this->setProducts(\App\Json::decode($client->getResponseBody()));
- Exclude checks
Spaces must 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 loadProduct(string $productId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->success = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Throwable $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $section
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->error = $client->getError();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get product by ID.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $productId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty(self::$productCache[$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
$className = '\\App\\YetiForce\\Shop\\Product\\YetiForceBase';
- Exclude checks
Spaces must 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->error = $e->getMessage();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setProducts([\App\Json::decode($client->getResponseBody())]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getProduct(string $name, string $productId = ''): ?Shop\AbstractBaseProduct
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->success = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->success = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error($e->getMessage(), __METHOD__);
- Exclude checks
Spaces must 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 ($productId) {
- 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
$client = new ApiClient();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new self())->load();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$productCache[$name] ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $className;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Throwable $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$client->send(self::URL . '/' . \App\Version::get() . "/products/{$productId}", 'GET');
- Exclude checks
Spaces must 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
* @param array $products
- Exclude checks
Spaces must 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
$className = '\\App\\YetiForce\\Shop\\Product\\' . $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function setProducts(array $products)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$productCache[$product->getName()] = $product;
- Exclude checks