TweetCreated::createFromArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace FAPI\Boilerplate\Model\Tweet;
11
12
use FAPI\Boilerplate\Model\CreatableFromArray;
13
14
/**
15
 * @author Tobias Nyholm <[email protected]>
16
 */
17 View Code Duplication
final class TweetCreated implements CreatableFromArray
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    /**
20
     * @var string
21
     */
22
    private $message;
23
24
    /**
25
     * @param string $message
26
     */
27
    private function __construct(string $message)
28
    {
29
        $this->message = $message;
30
    }
31
32
    /**
33
     * @param array $data
34
     *
35
     * @return TweetCreated
36
     */
37
    public static function createFromArray(array $data): TweetCreated
38
    {
39
        $message = '';
40
41
        if (isset($data['message'])) {
42
            $message = $data['message'];
43
        }
44
45
        return new self($message);
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getMessage(): string
52
    {
53
        return $this->message;
54
    }
55
}
56