These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Wikibase\Api\Lookup; |
||
4 | |||
5 | use Wikibase\Api\Service\RevisionGetter; |
||
6 | use Wikibase\DataModel\Entity\EntityId; |
||
7 | use Wikibase\DataModel\Services\Lookup\EntityLookup; |
||
8 | |||
9 | /** |
||
10 | * @author Addshore |
||
11 | * |
||
12 | * @access private |
||
13 | */ |
||
14 | class EntityApiLookup implements EntityLookup { |
||
15 | |||
16 | /** |
||
17 | * @param RevisionGetter $revisionGetter |
||
18 | */ |
||
19 | public function __construct( RevisionGetter $revisionGetter ) { |
||
20 | $this->revisionGetter = $revisionGetter; |
||
0 ignored issues
–
show
|
|||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @see EntityLookup::getEntity |
||
25 | */ |
||
26 | public function getEntity( EntityId $entityId ) { |
||
27 | $revision = $this->revisionGetter->getFromId( $entityId ); |
||
28 | |||
29 | if( !$revision ) { |
||
30 | return null; |
||
31 | } |
||
32 | |||
33 | return $revision->getContent()->getData(); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @see EntityLookup::hasEntity |
||
38 | */ |
||
39 | public function hasEntity( EntityId $entityId ) { |
||
40 | $revision = $this->revisionGetter->getFromId( $entityId ); |
||
41 | |||
42 | if( !$revision ) { |
||
43 | return false; |
||
44 | } |
||
45 | |||
46 | return true; |
||
47 | } |
||
48 | } |
||
49 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: