Showing 316 of 316 total issues
Api
has 37 functions (exceeds 20 allowed). Consider refactoring. Open
class Api
{
/**
* Kit version number
File Api.php
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Prismic;
Predicates
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class Predicates
{
/**
* @param string $fragment
The class SearchForm has 13 public methods. Consider refactoring SearchForm to keep number of public methods under 10. Open
class SearchForm
{
/**
* @var Api
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Api has 12 public methods. Consider refactoring Api to keep number of public methods under 10. Open
class Api
{
/**
* Kit version number
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Predicates has 27 public methods. Consider refactoring Predicates to keep number of public methods under 10. Open
class Predicates
{
/**
* @param string $fragment
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class FragmentCollection has an overall complexity of 63 which is very high. The configured complexity threshold is 50. Open
class FragmentCollection implements CompositeFragmentInterface
{
/** @var FragmentInterface[] */
protected $fragments = [];
- Exclude checks
The class Api has an overall complexity of 70 which is very high. The configured complexity threshold is 50. Open
class Api
{
/**
* Kit version number
- Exclude checks
The class Predicates has 27 non-getter- and setter-methods. Consider refactoring Predicates to keep number of methods under 25. Open
class Predicates
{
/**
* @param string $fragment
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
Function v2Factory
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private function v2Factory(string $key, $value, LinkResolver $linkResolver) : void
{
if ($this->isEmptyFragment($value)) {
return;
}
- 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 v2Factory
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function v2Factory(string $key, $value, LinkResolver $linkResolver) : void
{
if ($this->isEmptyFragment($value)) {
return;
}
Method factory
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function factory($value, LinkResolver $linkResolver) : FragmentInterface
{
$richText = new static;
// In API V2, Rich text is an array of 'Block Level' objects,
// in V1, the array is in the property 'value'
Function abstractFactory
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function abstractFactory($value, LinkResolver $linkResolver) :? LinkInterface
{
// Inspect payload to determine link type
$linkType = isset($value->link_type) ? $value->link_type : null;
$linkType = isset($value->value) && isset($value->type) ? $value->type : $linkType;
- 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 factory
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function factory($value, LinkResolver $linkResolver) : FragmentInterface
{
$richText = new static;
// In API V2, Rich text is an array of 'Block Level' objects,
// in V1, the array is in the property 'value'
- 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 abstractFactory
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function abstractFactory($value, LinkResolver $linkResolver) :? LinkInterface
{
// Inspect payload to determine link type
$linkType = isset($value->link_type) ? $value->link_type : null;
$linkType = isset($value->value) && isset($value->type) ? $value->type : $linkType;
Function insertSpans
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function insertSpans(string $text, array $spans, LinkResolver $linkResolver) : string
{
if (empty($spans)) {
return nl2br($this->escapeHtml($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
Function htmlAttributes
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function htmlAttributes(array $attributes) : string
{
$html = '';
foreach ($attributes as $key => $val) {
$key = $this->escapeHtml($key);
- 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 v1Factory
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function v1Factory(string $key, $value, LinkResolver $linkResolver) : void
{
$fragment = null;
switch ($value->type) {
case 'Image':
Method insertSpans
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function insertSpans(string $text, array $spans, LinkResolver $linkResolver) : string
{
if (empty($spans)) {
return nl2br($this->escapeHtml($text));
}
Method set
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set(string $key, $value) : self
{
if (empty($key)) {
throw new Exception\InvalidArgumentException('Form parameter key must be a non-empty string');
}