1 | <?php |
||
7 | class User |
||
8 | { |
||
9 | /** |
||
10 | * This class is a ghost object that lazy loads the full record only when needed. |
||
11 | * If $initialized is false, it means we haven't yet loaded the full record. |
||
12 | * We can still have incomplete data from a search response. |
||
13 | */ |
||
14 | protected $initialized = false; |
||
15 | |||
16 | protected $client; |
||
17 | |||
18 | protected $id; |
||
19 | |||
20 | protected $_identifiers; |
||
21 | |||
22 | /* @var \stdClass */ |
||
23 | protected $data; |
||
24 | |||
25 | /** |
||
26 | * Create a user from a search response containing an incomplete user record. |
||
27 | * |
||
28 | * @param Client $client |
||
29 | * @param \stdClass $data |
||
30 | * |
||
31 | * @return User |
||
32 | */ |
||
33 | public static function fromSearchResponse(Client $client, \stdClass $data) |
||
38 | |||
39 | /** |
||
40 | * User constructor. |
||
41 | * |
||
42 | * @param Client $client |
||
43 | * @param string $id |
||
44 | */ |
||
45 | public function __construct(Client $client, $id) |
||
50 | |||
51 | /** |
||
52 | * Load data on this User object. Chainable method. |
||
53 | * |
||
54 | * @param \stdClass $data |
||
55 | * |
||
56 | * @return User |
||
57 | */ |
||
58 | public function init($data = null) |
||
77 | |||
78 | /** |
||
79 | * Get the complete user record. |
||
80 | * |
||
81 | * @return \stdClass |
||
82 | */ |
||
83 | public function getData() |
||
87 | |||
88 | /** |
||
89 | * Get the primary id. No need to load the full record for this. |
||
90 | * |
||
91 | * @return string|null |
||
92 | */ |
||
93 | public function getPrimaryId() |
||
97 | |||
98 | /** |
||
99 | * Get the user identifiers. |
||
100 | * |
||
101 | * @return UserIdentifier[] |
||
102 | */ |
||
103 | public function getIdentifiers() |
||
107 | |||
108 | /** |
||
109 | * Magic! |
||
110 | */ |
||
111 | public function __get($key) |
||
138 | } |
||
139 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.