1 | <?php |
||
7 | abstract class AbstractProvider |
||
8 | { |
||
9 | /** |
||
10 | * |
||
11 | * @var string |
||
12 | */ |
||
13 | private $version; |
||
14 | |||
15 | protected $defaultValues = []; |
||
16 | |||
17 | /** |
||
18 | * Per default the provider cannot detect anything |
||
19 | * Activate them in $detectionCapabilities |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $allDetectionCapabilities = [ |
||
24 | 'browser' => [ |
||
25 | 'name' => false, |
||
26 | 'version' => false, |
||
27 | ], |
||
28 | |||
29 | 'renderingEngine' => [ |
||
30 | 'name' => false, |
||
31 | 'version' => false, |
||
32 | ], |
||
33 | |||
34 | 'operatingSystem' => [ |
||
35 | 'name' => false, |
||
36 | 'version' => false, |
||
37 | ], |
||
38 | |||
39 | 'device' => [ |
||
40 | 'model' => false, |
||
41 | 'brand' => false, |
||
42 | 'type' => false, |
||
43 | 'isMobile' => false, |
||
44 | 'isTouch' => false, |
||
45 | ], |
||
46 | |||
47 | 'bot' => [ |
||
48 | 'isBot' => false, |
||
49 | 'name' => false, |
||
50 | 'type' => false, |
||
51 | ], |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * Set this in each Provider implementation |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $detectionCapabilities = []; |
||
60 | |||
61 | /** |
||
62 | * Return the name of the provider |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | abstract public function getName(); |
||
67 | |||
68 | abstract public function getComposerPackageName(); |
||
69 | |||
70 | /** |
||
71 | * Return the version of the provider |
||
72 | * |
||
73 | * @return string null |
||
74 | */ |
||
75 | 2 | public function getVersion() |
|
101 | |||
102 | /** |
||
103 | * |
||
104 | * @return \stdClass null |
||
105 | */ |
||
106 | 2 | private function getComposerPackages() |
|
121 | |||
122 | /** |
||
123 | * What kind of capabilities this provider can detect |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | 1 | public function getDetectionCapabilities() |
|
131 | |||
132 | /** |
||
133 | * |
||
134 | * @param mixed $value |
||
135 | * @param array $additionalDefaultValues |
||
136 | * @return boolean |
||
137 | */ |
||
138 | 2 | protected function isRealResult($value, array $additionalDefaultValues = []) |
|
154 | |||
155 | /** |
||
156 | * Parse the given user agent and return a result if possible |
||
157 | * |
||
158 | * @param string $userAgent |
||
159 | * @param array $headers |
||
160 | * |
||
161 | * @throws Exception\NoResultFoundException |
||
162 | * |
||
163 | * @return Model\UserAgent |
||
164 | */ |
||
165 | abstract public function parse($userAgent, array $headers = []); |
||
166 | } |
||
167 |