1 | <?php |
||
15 | class MessageSearch |
||
16 | { |
||
17 | /** |
||
18 | * The MySQL query builder for messages |
||
19 | * @var \MessageQueryBuilder |
||
20 | */ |
||
21 | private $queryBuilder; |
||
22 | |||
23 | /** |
||
24 | * The user to whom the returned messages will be visible |
||
25 | * @var \Player|null |
||
26 | */ |
||
27 | private $player; |
||
28 | |||
29 | /** |
||
30 | * Create a new message search |
||
31 | * |
||
32 | * @param \MessageQueryBuilder $queryBuilder The MySQL query builder for messages |
||
33 | * @param \Player|null $player The player to make the search for |
||
34 | */ |
||
35 | 1 | public function __construct(\MessageQueryBuilder $queryBuilder, \Player $player = null) |
|
40 | |||
41 | /** |
||
42 | * Perform a search on messages and get the results |
||
43 | * |
||
44 | * @param string $query The query string |
||
45 | * @return \Message[] The results of the search |
||
46 | */ |
||
47 | 1 | public function search($query) |
|
57 | |||
58 | /** |
||
59 | * Perform a search on messages using the data stored in the MySQL database |
||
60 | * |
||
61 | * @param string $query The query string |
||
62 | * @return \Message[] The results of the search |
||
63 | */ |
||
64 | 1 | private function mysqlSearch($query) |
|
71 | } |
||
72 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: