Passed
Branch master (8fa86f)
by Alexander
04:20
created

Person::fromJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
namespace Horat1us\Examples;
3
4
use Horat1us\XmlConvertible;
5
use Horat1us\XmlConvertibleInterface;
6
7
class Person implements XmlConvertibleInterface
8
{
9
    use XmlConvertible;
10
11
    public $name;
12
13
    public $surname;
14
15
    public static function fromJson(string $json): Person
16
    {
17
        $array = json_decode($json, true);
18
19
        $object = new static;
20
        $object->name = $array['name'] ?? null;
21
        $object->surname = $array['surname'] ?? null;
22
23
        return $object;
24
    }
25
}