Function create
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function create()
{
if (\array_diff_key($this->getData(), $this->template)) {
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
}
- 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
Function validate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function validate(string $key, $value)
{
if (!isset($this->template[$key])) {
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
}
- 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
Method create
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create()
{
if (\array_diff_key($this->getData(), $this->template)) {
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
}
Function loadTemplate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function loadTemplate()
{
if (!\file_exists($this->templatePath)) {
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $this->templatePath, 406);
}
- 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 method create() has an NPath complexity of 208. The configured NPath complexity threshold is 200. Open
public function create()
{
if (\array_diff_key($this->getData(), $this->template)) {
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method create() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function create()
{
if (\array_diff_key($this->getData(), $this->template)) {
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 22 to the 15 allowed. Open
public function create()
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Missing class import via use statement (line '231', column '15'). Open
$file = new \Nette\PhpGenerator\PhpFile();
- 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\Config' in method 'create'. Open
$value = $this->has($parameterName) ? $this->get($parameterName) : Config::get($className, $parameterName, $parameter['default']);
- 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 getClassName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$className .= ucfirst($this->type);
}
- 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
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->templatePath = 'config' . \DIRECTORY_SEPARATOR . 'ConfigTemplates.php';
$this->path = 'config' . \DIRECTORY_SEPARATOR . \ucfirst($this->type) . '.php';
}
- 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
The method create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
require "{$this->path}";
}
- 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 'create'. Open
Cache::resetFileCache($this->path);
- 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 create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = $this->has($parameterName) ? $this->get($parameterName) : Config::get($className, $parameterName, $parameter['default']);
$property = $class->addProperty($parameterName, $value)->setStatic()->addComment($parameter['description']);
}
- 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 'loadTemplate'. Open
Cache::resetFileCache($this->templatePath);
- 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
Define a constant instead of duplicating this literal "config" 5 times. Open
$this->path = 'config' . \DIRECTORY_SEPARATOR . 'Modules' . \DIRECTORY_SEPARATOR . "{$component}.php";
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "sanitization" 4 times. Open
if (isset($this->template[$key]['sanitization'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "ERR_NOT_ALLOWED_VALUE||" 4 times. Open
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $type, 406);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "validationValues" 3 times. Open
if (isset($this->template[$key]['validationValues']) && \is_array($this->template[$key]['validationValues'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "validation" 4 times. Open
if (true !== \call_user_func_array($this->template[$key]['validation'], [$row])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "module" 4 times. Open
'module',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "component" 4 times. Open
'component',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to method addComment
from undeclared class \Nette\PhpGenerator\PhpFile
Open
$file->addComment($this->license);
- Exclude checks
Call to method addClass
from undeclared class \Nette\PhpGenerator\PhpFile
Open
$class = $file->addClass($className);
- Exclude checks
Suspicious array access to ?mixed
Open
$property = $class->addProperty($parameterName, $value)->setStatic()->addComment($parameter['description']);
- Exclude checks
Suspicious array access to ?mixed
Open
$value = $this->has($parameterName) ? $this->get($parameterName) : Config::get($className, $parameterName, $parameter['default']);
- Exclude checks
Call to method __construct
from undeclared class \Nette\PhpGenerator\PhpFile
Open
$file = new \Nette\PhpGenerator\PhpFile();
- Exclude checks
Spaces must 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->templatePath = 'modules' . \DIRECTORY_SEPARATOR . $component . \DIRECTORY_SEPARATOR . 'ConfigTemplate.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'relation',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $path;
- Exclude checks
Spaces must 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 (!\in_array($type, self::TYPES)) {
- 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
/** @var string|null Component name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $component;
- Exclude checks
Spaces must 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
'performance',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Path to the configuration file */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $component
- Exclude checks
Spaces must 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|null $key
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = \call_user_func_array($this->template[$key]['sanitization'], [$value]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $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
$class->addComment("Configuration file: $className.");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $license = 'Configuration file.
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$this->templatePath = 'config' . \DIRECTORY_SEPARATOR . 'Components' . \DIRECTORY_SEPARATOR . 'ConfigTemplates.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load configuration template.
- Exclude checks
Spaces must 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 mixed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $key ? ($this->template[$key] ?? null) : $this->template;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function for data validation.
- Exclude checks
Spaces must 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 true === \call_user_func_array($this->template[$key]['validation'], [$value]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $key
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Create configuration file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\array_diff_key($this->getData(), $this->template)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $this->has($parameterName) ? $this->get($parameterName) : Config::get($className, $parameterName, $parameter['default']);
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
$property = $class->addProperty($parameterName, $value)->setStatic()->addComment($parameter['description']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'component',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string License */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->path = 'config' . \DIRECTORY_SEPARATOR . 'Modules' . \DIRECTORY_SEPARATOR . "{$component}.php";
- Exclude checks
Spaces must 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 .= 'Modules\\' . $this->component;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className .= ucfirst($this->type);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \in_array($value, $this->template[$key]['validationValues']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$status = true;
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
throw new Exceptions\AppException("ERR_CONTENTS_VARIABLE_CANT_CALLED_FUNCTION ||{$this->template[$key]['sanitization']}", 406);
- Exclude checks
Spaces must 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'debug',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Template 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
$this->type = $type;
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$this->templatePath = 'modules' . \DIRECTORY_SEPARATOR . $component . \DIRECTORY_SEPARATOR . 'ConfigTemplate.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($data[$this->type])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $this->type, 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->template = $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
private function getClassName()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->template[$key]['validationValues']) && \is_array($this->template[$key]['validationValues'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (true !== \call_user_func_array($this->template[$key]['validation'], [$row])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$property->addComment("@{$tagName} {$val}");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Path to the configuration template file */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->loadTemplate();
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function validate(string $key, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return self
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
$value = $this->has($parameterName) ? $this->get($parameterName) : Config::get($className, $parameterName, $parameter['default']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'api',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'developer',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct(string $type, ?string $component = '')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::__construct();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($component) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $data[$this->type];
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return mixed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function sanitize(string $key, $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
public function create()
- Exclude checks
Spaces must 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 ($parameter['docTags'] as $tagName => $val) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$property->addComment('');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($className::${$name})) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Types of configuration files */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'module',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sounds',
- Exclude checks
Spaces must 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 ('component' === $this->type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->templatePath = 'config' . \DIRECTORY_SEPARATOR . 'ConfigTemplates.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->path = 'config' . \DIRECTORY_SEPARATOR . \ucfirst($this->type) . '.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\IllegalValue("ERR_NOT_ALLOWED_VALUE||{$this->type}:{$this->component}", 406);
- Exclude checks
Spaces must 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 (!empty($this->template[$key]['loopValidate'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $status;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function set($key, $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
$className::${$name} = $property->getValue();
- Exclude checks
Spaces must 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->path = 'config' . \DIRECTORY_SEPARATOR . 'Components' . \DIRECTORY_SEPARATOR . "{$component}.php";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets class name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('module' === $this->type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->template[$key])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function for data sanitize.
- Exclude checks
Spaces must 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
foreach ($this->template as $parameterName => $parameter) {
- Exclude checks
Spaces must 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 TYPES = [
- Exclude checks
Spaces must 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 function loadTemplate()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $data[$this->component];
- 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
foreach ($value as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require "{$this->path}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* ConfigFile constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $type, 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->component = $component;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = require "{$this->templatePath}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($data[$this->component])) {
- Exclude checks
Spaces must 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 $key
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file->addComment($this->license);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::resetFileCache($this->path);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'db',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'security',
- Exclude checks
Spaces must 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 ('module' === $this->type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('module' !== $this->type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->template[$key]['validation']) || !\is_callable($this->template[$key]['validation'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\AppException("ERR_CONTENTS_VARIABLE_CANT_CALLED_FUNCTION ||{$this->template[$key]['sanitization']}", 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\IllegalValue("ERR_NOT_ALLOWED_VALUE||{$key}||" . \var_export($value, true), 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\IllegalValue
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
$property = $class->addMethod($parameterName)->setStatic()->setBody($parameter['default'])->addComment($parameter['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
'main',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'layout',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $template = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->templatePath = 'config' . \DIRECTORY_SEPARATOR . 'Components' . \DIRECTORY_SEPARATOR . 'ConfigTemplates.php';
- Exclude checks
Spaces must 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
break;
- Exclude checks
Spaces must 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 (isset($this->template[$key]['sanitization'])) {
- Exclude checks
Spaces must 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 mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$property = $class->addMethod($parameterName)->setStatic()->setBody($parameter['default'])->addComment($parameter['description']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($parameter['docTags'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'securityKeys',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'search',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Type of configuration file */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $templatePath;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $this->templatePath, 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className .= 'Components\\' . $this->component;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets template 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
}
- Exclude checks
Spaces must 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 parent::set($key, $this->sanitize($key, $value));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = new \Nette\PhpGenerator\PhpFile();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($parameter['type']) && 'function' === $parameter['type']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('component' === $this->type) {
- Exclude checks
Spaces must 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 mixed $value
- 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
$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
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\is_callable($this->template[$key]['sanitization'])) {
- Exclude checks
Spaces must 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 = $this->getClassName();
- 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
throw new Exceptions\AppException("ERR_CREATE_FILE_FAILURE||{$this->path}");
- Exclude checks
Spaces must 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 (!\file_exists($this->templatePath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::resetFileCache($this->templatePath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('component' === $this->type) {
- Exclude checks
Spaces must 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 = 'Config\\';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getTemplate(?string $key = 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->validate($key, $value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$class = $file->addClass($className);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$property = $class->addProperty($parameterName, $value)->setStatic()->addComment($parameter['description']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($class->getProperties() as $name => $property) {
- Exclude checks
Spaces must 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 $key
- Exclude checks
Spaces must 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
throw new Exceptions\AppException("ERR_CONTENTS_VARIABLE_CANT_CALLED_FUNCTION||{$key}", 406);
- Exclude checks
Spaces must 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 (\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
if (false === file_put_contents($this->path, $file, LOCK_EX)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks