JsonModel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A jsonUnserialize() 0 4 1
1
<?php
2
3
4
namespace flipbox\saml\core\models;
5
6
trait JsonModel
7
{
8
9
    /**
10
     * @return array|mixed
11
     */
12
    public function __toString()
13
    {
14
        return json_encode($this);
15
    }
16
17
    /**
18
     * @param string $json
19
     * @return mixed
20
     */
21
    public static function jsonUnserialize(string $json)
22
    {
23
        return new static(json_decode($json, true));
0 ignored issues
show
Unused Code introduced by
The call to JsonModel::__construct() has too many arguments starting with json_decode($json, true).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
24
    }
25
}
26