1 | <?php |
||
18 | class ApprovedDatePropertyAnnotator implements PropertyAnnotator { |
||
19 | |||
20 | /** |
||
21 | * Predefined property ID |
||
22 | */ |
||
23 | const PROP_ID = '___APPROVEDDATE'; |
||
24 | |||
25 | /** |
||
26 | * @var AppFactory |
||
27 | */ |
||
28 | private $appFactory; |
||
29 | |||
30 | /** |
||
31 | * @var Integer|null |
||
32 | */ |
||
33 | private $approvedDate; |
||
34 | |||
35 | /** |
||
36 | * @param AppFactory $appFactory |
||
37 | */ |
||
38 | public function __construct( AppFactory $appFactory ) { |
||
41 | |||
42 | /** |
||
43 | * @since 2.0 |
||
44 | * |
||
45 | * @param Integer $approvedDate |
||
46 | */ |
||
47 | public function setApprovedDate( $approvedDate ) { |
||
50 | |||
51 | /** |
||
52 | * {@inheritDoc} |
||
53 | */ |
||
54 | public function isAnnotatorFor( DIProperty $property ) { |
||
57 | |||
58 | public function getDataItem() { |
||
59 | if ( $this->approvedDate ) { |
||
|
|||
60 | $date = $this->approvedDate; |
||
61 | return new DITime( |
||
62 | DITime::CM_GREGORIAN, |
||
63 | $date->format( 'Y' ), |
||
64 | $date->format( 'm' ), |
||
65 | $date->format( 'd' ), |
||
66 | $date->format( 'H' ), |
||
67 | $date->format( 'i' ) |
||
68 | ); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * {@inheritDoc} |
||
74 | */ |
||
75 | public function addAnnotation( |
||
92 | } |
||
93 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: