Arrayable   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 7
eloc 13
c 5
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 4 2
A inherit() 0 8 3
A __construct() 0 7 2
1
<?php
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "Arrayable.php" doesn't match the expected filename "arrayable.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
declare(strict_types=1);
4
5
namespace PHPAbles\Arrayable;
6
7
use Illuminate\Contracts\Support\Arrayable as IlluminateArrayable,
0 ignored issues
show
Coding Style introduced by
Header blocks must be separated by a single blank line
Loading history...
8
    Inspirum\Arrayable\Arrayable as InspirumArrayable,
9
    PhpExtended\Arrayable\ArrayableInterface as PhpExtendedArrayable;
10
11
final class Arrayable extends AbstractArrayable
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for class Arrayable
Loading history...
12
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Arrayable
Loading history...
13
    private array $array;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
Coding Style introduced by
Private member variable "array" must contain a leading underscore
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "array" must be prefixed with an underscore
Loading history...
14
    
15
    public function __construct(array|IlluminateArrayable|InspirumArrayable|PhpExtendedArrayable $array)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 104 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
16
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
17
        if (is_array($array)) {
0 ignored issues
show
introduced by
The condition is_array($array) is always true.
Loading history...
18
            $this->array = $array;
19
            return;
20
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
21
        $this->inherit($array);
22
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __construct()
Loading history...
23
    
24
    public function toArray(): array
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function toArray()
Loading history...
25
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
26
        $array = parent::toArray();
27
        return array_key_exists('array', $array) ? $array['array'] : [];
0 ignored issues
show
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
28
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end toArray()
Loading history...
29
    
30
    private function inherit(IlluminateArrayable|InspirumArrayable|PhpExtendedArrayable $arrayable): void
0 ignored issues
show
Coding Style introduced by
Private method name "Arrayable::inherit" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function inherit()
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 105 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
31
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
32
        if (($arrayable instanceOf IlluminateArrayable) ||
0 ignored issues
show
Coding Style introduced by
The first expression of a multi-line control structure must be on the line after the opening parenthesis
Loading history...
Coding Style introduced by
As per coding-style, PHP keywords should be in lowercase; expected instanceof, but found instanceOf.
Loading history...
33
            ($arrayable instanceOf PhpExtendedArrayable)) {
0 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
Coding Style introduced by
As per coding-style, PHP keywords should be in lowercase; expected instanceof, but found instanceOf.
Loading history...
Coding Style introduced by
The closing parenthesis of a multi-line control structure must be on the line after the last expression
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
34
            $this->array = $arrayable->toArray();
35
            return;
36
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
37
        $this->array = $arrayable->__toArray();
38
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end inherit()
Loading history...
39
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
40