-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice.php
More file actions
142 lines (125 loc) · 3.49 KB
/
Copy pathDevice.php
File metadata and controls
142 lines (125 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
* This file is part of the mimmi20/ua-result package.
*
* Copyright (c) 2015-2026, Thomas Mueller <mimmi20@live.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types = 1);
namespace UaResult\Device;
use Override;
use UaData\CompanyInterface;
use UaDeviceType\Type;
use UaResult\Bits\Bits;
final class Device implements DeviceInterface
{
/** @throws void */
public function __construct(
private readonly Architecture $architecture,
private readonly string | null $deviceName,
private readonly string | null $marketingName,
private CompanyInterface $manufacturer,
private CompanyInterface $brand,
private readonly Type $type,
private DisplayInterface $display,
private readonly bool | null $dualOrientation,
private readonly int | null $simCount,
private readonly Bits $bits,
) {
// nothing to do
}
/**
* clones the actual object
*
* @throws void
*/
public function __clone()
{
$this->manufacturer = clone $this->manufacturer;
$this->brand = clone $this->brand;
$this->display = clone $this->display;
}
/** @throws void */
#[Override]
public function getArchitecture(): Architecture
{
return $this->architecture;
}
/** @throws void */
#[Override]
public function getDeviceName(): string | null
{
return $this->deviceName;
}
/** @throws void */
#[Override]
public function getBrand(): CompanyInterface
{
return $this->brand;
}
/** @throws void */
#[Override]
public function getManufacturer(): CompanyInterface
{
return $this->manufacturer;
}
/** @throws void */
#[Override]
public function getMarketingName(): string | null
{
return $this->marketingName;
}
/** @throws void */
#[Override]
public function getDisplay(): DisplayInterface
{
return $this->display;
}
/** @throws void */
#[Override]
public function getType(): Type
{
return $this->type;
}
/** @throws void */
#[Override]
public function getDualOrientation(): bool | null
{
return $this->dualOrientation;
}
/** @throws void */
#[Override]
public function getSimCount(): int | null
{
return $this->simCount;
}
/** @throws void */
#[Override]
public function getBits(): Bits
{
return $this->bits;
}
/**
* @return array{architecture: Architecture, deviceName: string|null, marketingName: string|null, manufacturer: string, brand: string, type: string, display: array{width: int|null, height: int|null, touch: bool|null, size: float|null}, dualOrientation: bool|null, simCount: int|null, bits: Bits}
*
* @throws void
*/
#[Override]
public function toArray(): array
{
return [
'architecture' => $this->architecture,
'deviceName' => $this->deviceName,
'marketingName' => $this->marketingName,
'manufacturer' => $this->manufacturer->getKey(),
'brand' => $this->brand->getKey(),
'display' => $this->display->toArray(),
'type' => $this->type->getType(),
'dualOrientation' => $this->dualOrientation,
'simCount' => $this->simCount,
'bits' => $this->bits,
];
}
}