ExternalEntity::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace ExternalFeedParser\Entity;
4
5
use Illuminate\Support\Arr;
6
7
/**
8
 * DTO class between package and app
9
 */
10
class ExternalEntity
11
{
12 3
    public function __construct(
13
        protected array $data = []
14
    ) {
15 3
    }
16
17 2
    public function get(string|null $key = null, mixed $default = null): mixed
18
    {
19 2
        if (is_null($key)) {
20 2
            return $this->data;
21
        }
22
23 2
        return Arr::get($this->data, $key, $default);
24
    }
25
}
26