Showing 8 of 11 total issues
Function dataFromTag
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function dataFromTag(KirbyTag $tag)
{
$data = [];
foreach ($this->attrKeys() as $attr) {
$val = $tag->$attr;
- 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 normalizeData
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function normalizeData(array $data)
{
$norm = [];
foreach ($data as $key => $val) {
if (is_string($val) && $val === 'true') {
- 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 applySrcset
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function applySrcset(string $text, array $data = []): string
{
$srcfile = new SrcsetFile(
A::get($data, 'file'),
A::get($data, 'sizes'),
Method dataFromTag
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function dataFromTag(KirbyTag $tag)
{
$data = [];
foreach ($this->attrKeys() as $attr) {
$val = $tag->$attr;
Function imageKirbytagFromData
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function imageKirbytagFromData(array $data = []): string
{
$attrs = ['(image: ' . self::PLACEHOLDER]; // A::get($data, 'value')
$lazy = A::get($data, 'lazy');
if ($lazy) {
- 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 __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(File $file, $sizes = null, ?int $width = null, ?int $height = null, ?int $quality = null)
Function applySrcset
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function applySrcset(string $text, array $data = []): string
{
$srcfile = new SrcsetFile(
A::get($data, 'file'),
A::get($data, 'sizes'),
- 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 __construct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($data = null, array $options = [])
{
if (is_a($data, 'Kirby\Cms\KirbyTag')) {
$this->parent = $data->parent();
$options = $this->dataFromTag($data);
- 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"