Passed
Pull Request — master (#46)
by Artem
13:08
created

DeviceInfo::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoman4eg\Nalog\DTO;
5
6
/**
7
 * @author Artem Dubinin <[email protected]>
8
 */
9
final readonly class DeviceInfo implements \JsonSerializable
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 9 at column 6
Loading history...
10
{
11
    public const SOURCE_TYPE_WEB = 'WEB';
12
    public const APP_VERSION = '1.0.0';
13
    public const USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36';
14
15
    public function __construct(
16
        private string $deviceId,
17
        private string $type = self::SOURCE_TYPE_WEB,
18
        private string $appVersion = self::APP_VERSION,
19
        private string $userAgent = self::USER_AGENT
20
    ) {}
21
22
    public function jsonSerialize(): array
23
    {
24
        return [
25
            'sourceType' => $this->type,
26
            'sourceDeviceId' => $this->deviceId,
27
            'appVersion' => $this->appVersion,
28
            'metaDetails' => ['userAgent' => $this->userAgent],
29
        ];
30
    }
31
}
32