1 | <?php |
||
12 | abstract class AbstractScaleEngineModelFactory |
||
13 | { |
||
14 | /** @type string The expected date format ScaleEngine uses. **/ |
||
15 | const SCALEENGINE_DATE_FORMAT = 'Y-m-d H:i:s'; |
||
16 | |||
17 | /** @type string The full date string ScaleEngine uses for a null date. **/ |
||
18 | const SCALEENGINE_NULL_DATE = '0000-00-00 00:00:00'; |
||
19 | |||
20 | /** @type string The timezone ScaleEngine uses for its dates. **/ |
||
21 | const SCALEENGINE_TIMEZONE = 'UTC'; |
||
22 | |||
23 | /** @type model The model class name. **/ |
||
24 | private $_model; |
||
25 | |||
26 | /** @type array A map of keys from ScaleEngine's API to exposed model. **/ |
||
27 | private $_keyMap; |
||
28 | |||
29 | /** @type array The data stored for the model. **/ |
||
30 | private $_data; |
||
|
|||
31 | |||
32 | /** |
||
33 | * Create the model factory for a specific type of model. |
||
34 | * |
||
35 | * @param string $model The full class name for the model to construct. |
||
36 | * @param array $keyMap A map of keys from ScaleEngine's API to exposed model. |
||
37 | */ |
||
38 | public function __construct($model, array $keyMap) |
||
43 | |||
44 | /** |
||
45 | * Create a Ticket model using the provided data. |
||
46 | * |
||
47 | * The data given will be parsed and any missing keys will result in |
||
48 | * failure. |
||
49 | * |
||
50 | * @param array $data The data to use to populate the model. |
||
51 | * @return self The parsed model. |
||
52 | */ |
||
53 | public function create(array $data) |
||
58 | |||
59 | /** |
||
60 | * Parse the data given into correct types and changes keys based on the |
||
61 | * `KEY_MAP`. |
||
62 | * |
||
63 | * @param array $data The ticket data to parse. |
||
64 | * @return array The data after being converted to the parsed form. |
||
65 | */ |
||
66 | abstract public function parseData(array $data); |
||
67 | |||
68 | /** |
||
69 | * Convert a date from ScaleEngine's format into a PHP DateTime. |
||
70 | * |
||
71 | * ScaleEngine uses an all-zeros response for null dates, and this will |
||
72 | * convert those into null itself. |
||
73 | * |
||
74 | * This also considers that ScaleEngine uses UTC for its timezone and makes |
||
75 | * sure that the time returned is correct considering that behavior. |
||
76 | * |
||
77 | * @param string $date The date as returned from ScaleEngine. |
||
78 | * @return DateTime The converted date/time object. |
||
79 | */ |
||
80 | public function convertDate($date) |
||
92 | } |
||
93 |
This check marks private properties in classes that are never used. Those properties can be removed.