1 | <?php |
||
5 | class RackspaceLogParser |
||
6 | { |
||
7 | /** |
||
8 | * Rexeg Pattern to match Rackspace Cloud Files Logs. |
||
9 | */ |
||
10 | const PATTERN = '/^([^ ]+) ([^ ]+) ([^ ]+) (\[[^\]]+\]) "(.*) (.*) (.*)" ([0-9\-]+) ([0-9\-]+) "(.*)" "(.*)/m'; |
||
11 | |||
12 | /** |
||
13 | * Max Buffer size for reading log file. |
||
14 | */ |
||
15 | const BUFFER_SIZE = 4096; |
||
16 | |||
17 | /** |
||
18 | * The path to the log file. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $path; |
||
23 | |||
24 | /** |
||
25 | * The log file in memory. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $log; |
||
30 | |||
31 | /** |
||
32 | * Create a new RackspaceLogParser Instance. |
||
33 | * |
||
34 | * @param string $path |
||
35 | */ |
||
36 | public function __construct($path) |
||
41 | |||
42 | /** |
||
43 | * Parse a log file into an arrray of LogItems. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function parse() |
||
58 | |||
59 | /** |
||
60 | * read a log file into memory. |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | private function processLog() |
||
82 | |||
83 | /** |
||
84 | * Get the rows of a log. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | private function getLogRows() |
||
92 | |||
93 | /** |
||
94 | * Parse a row into its component parts. |
||
95 | * |
||
96 | * @param string $row |
||
97 | * @return array |
||
98 | */ |
||
99 | private function parseRow($row) |
||
105 | |||
106 | /** |
||
107 | * Create a Log Item from a parsed log row. |
||
108 | * |
||
109 | * @param array $entry |
||
110 | * @return LogItem |
||
111 | */ |
||
112 | private function createLogItem($entry) |
||
129 | |||
130 | /** |
||
131 | * Parse a log date. |
||
132 | * |
||
133 | * @param string $date |
||
134 | * @return \Carbon\Carbon |
||
135 | */ |
||
136 | private function parseDate($date) |
||
144 | } |
||
145 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..