1 | <?php namespace Arcanedev\LaravelTracker\Parsers; |
||
11 | class RefererParser implements RefererParserContract |
||
12 | { |
||
13 | /* ------------------------------------------------------------------------------------------------ |
||
14 | | Properties |
||
15 | | ------------------------------------------------------------------------------------------------ |
||
16 | */ |
||
17 | /** |
||
18 | * Referer parser instance. |
||
19 | * |
||
20 | * @var \Snowplow\RefererParser\Parser |
||
21 | */ |
||
22 | private $parser; |
||
23 | |||
24 | /** |
||
25 | * Parsed referer instance. |
||
26 | * |
||
27 | * @var \Snowplow\RefererParser\Referer |
||
28 | */ |
||
29 | private $referer; |
||
30 | |||
31 | /* ------------------------------------------------------------------------------------------------ |
||
32 | | Constructor |
||
33 | | ------------------------------------------------------------------------------------------------ |
||
34 | */ |
||
35 | /** |
||
36 | * RefererParser constructor. |
||
37 | * |
||
38 | * @param \Snowplow\RefererParser\Parser $parser |
||
39 | */ |
||
40 | 36 | public function __construct($parser) |
|
44 | |||
45 | /* ------------------------------------------------------------------------------------------------ |
||
46 | | Getters & Setters |
||
47 | | ------------------------------------------------------------------------------------------------ |
||
48 | */ |
||
49 | /** |
||
50 | * Set the referer. |
||
51 | * |
||
52 | * @param \Snowplow\RefererParser\Referer $referer |
||
53 | * |
||
54 | * @return self |
||
55 | */ |
||
56 | 6 | public function setReferer($referer) |
|
62 | |||
63 | /** |
||
64 | * Get the search medium. |
||
65 | * |
||
66 | * @return string|null |
||
67 | */ |
||
68 | 6 | public function getMedium() |
|
72 | |||
73 | /** |
||
74 | * Get the search source. |
||
75 | * |
||
76 | * @return string|null |
||
77 | */ |
||
78 | 6 | public function getSource() |
|
82 | |||
83 | /** |
||
84 | * Get the search term. |
||
85 | * |
||
86 | * @return string|null |
||
87 | */ |
||
88 | 6 | public function getSearchTerm() |
|
92 | |||
93 | /** |
||
94 | * Check if the referer is known. |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | 6 | public function isKnown() |
|
102 | |||
103 | /* ------------------------------------------------------------------------------------------------ |
||
104 | | Main Functions |
||
105 | | ------------------------------------------------------------------------------------------------ |
||
106 | */ |
||
107 | /** |
||
108 | * Parse a referer. |
||
109 | * |
||
110 | * @param string $refererUrl |
||
111 | * @param string $pageUrl |
||
112 | * |
||
113 | * @return self |
||
114 | */ |
||
115 | 6 | public function parse($refererUrl, $pageUrl) |
|
121 | |||
122 | /** |
||
123 | * Parse the referer url. |
||
124 | * |
||
125 | * @param string $referer |
||
126 | * |
||
127 | * @return array |
||
128 | */ |
||
129 | 12 | public function parseUrl($referer) |
|
146 | } |
||
147 |