Campaign.php
3 years ago
Current_Traffic.php
3 years ago
Device.php
2 years ago
Geo.php
2 years ago
Page.php
2 years ago
Page_Author_Archive.php
3 years ago
Page_Date_Archive.php
3 years ago
Page_Home.php
3 years ago
Page_Not_Found.php
3 years ago
Page_Post_Type_Archive.php
2 years ago
Page_Search.php
3 years ago
Page_Singular.php
2 years ago
Page_Term_Archive.php
3 years ago
Referrer.php
2 years ago
View_Stats.php
2 years ago
Visitor.php
2 years ago
WooCommerce_Stats.php
3 years ago
Device.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Models; |
| 4 | |
| 5 | class Device |
| 6 | { |
| 7 | use View_Stats; |
| 8 | use WooCommerce_Stats; |
| 9 | private $device_ids; |
| 10 | private $type; |
| 11 | private $os; |
| 12 | private $browser; |
| 13 | public function __construct($row) |
| 14 | { |
| 15 | $this->device_ids = $row->device_ids; |
| 16 | $this->type = $row->type ?? null; |
| 17 | $this->os = $row->os ?? null; |
| 18 | $this->browser = $row->browser ?? null; |
| 19 | $this->set_view_stats($row); |
| 20 | $this->set_wc_stats($row); |
| 21 | } |
| 22 | public function device_type() |
| 23 | { |
| 24 | return $this->type; |
| 25 | } |
| 26 | public function browser() |
| 27 | { |
| 28 | return $this->browser; |
| 29 | } |
| 30 | public function os() |
| 31 | { |
| 32 | return $this->os; |
| 33 | } |
| 34 | /** |
| 35 | * @param Device[] $devices |
| 36 | * |
| 37 | * @return int[] |
| 38 | */ |
| 39 | public static function convert_devices_to_ids(array $devices) : array |
| 40 | { |
| 41 | if (\count($devices) === 0) { |
| 42 | return []; |
| 43 | } |
| 44 | $array_of_arrays = \array_map(function ($device) { |
| 45 | return $device->device_ids; |
| 46 | }, $devices); |
| 47 | return \array_merge(...$array_of_arrays); |
| 48 | } |
| 49 | } |
| 50 |