Showing 41 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
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');
}
Function v1Factory
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function v1Factory(string $key, $value, LinkResolver $linkResolver) : void
{
$fragment = null;
switch ($value->type) {
case 'Image':
- 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 submit
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function submit() : Response
{
if ($this->form->getMethod() !== 'GET' ||
$this->form->getEnctype() !== 'application/x-www-form-urlencoded' ||
! $this->form->getAction()
Method fromJsonObject
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromJsonObject(stdClass $data, Api $api) : DocumentInterface
{
$inst = new static;
$inst->api = $api;
$inst->id = $inst->assertRequiredProperty($data, 'id', false);
Method fromJson
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromJson($value, LinkResolver $linkResolver) : self
{
// Type and Label are the same for V1 & V2
$type = isset($value->slice_type)
? (string) $value->slice_type
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
array $refs,
array $bookmarks,
array $types,
array $tags,
array $forms,
Function set
has a Cognitive Complexity of 9 (exceeds 5 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');
}
- 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"