PersonaSettings   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 48
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A create() 0 4 1
A toArray() 0 9 1
A jsonSerialize() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model;
6
7
use Kerox\Messenger\Helper\ValidatorTrait;
8
9
class PersonaSettings implements \JsonSerializable
10
{
11
    use ValidatorTrait;
12
13
    /**
14
     * @var string
15
     */
16
    protected $name;
17
18
    /**
19
     * @var string
20
     */
21
    protected $profilePictureUrl;
22
23
    /**
24
     * Persona constructor.
25
     */
26 1
    public function __construct(string $name, string $profilePictureUrl)
27
    {
28 1
        $this->isValidUrl($profilePictureUrl);
29
30 1
        $this->name = $name;
31 1
        $this->profilePictureUrl = $profilePictureUrl;
32 1
    }
33
34
    /**
35
     * @return \Kerox\Messenger\Model\PersonaSettings
36
     */
37 1
    public static function create(string $name, string $profilePictureUrl): self
38
    {
39 1
        return new self($name, $profilePictureUrl);
40
    }
41
42 1
    public function toArray(): array
43
    {
44
        $array = [
45 1
            'name' => $this->name,
46 1
            'profile_picture_url' => $this->profilePictureUrl,
47
        ];
48
49 1
        return array_filter($array);
50
    }
51
52 1
    public function jsonSerialize(): array
53
    {
54 1
        return $this->toArray();
55
    }
56
}
57