1 | <?php |
||
12 | abstract class AbstractScaleEngineModelFactory |
||
13 | { |
||
14 | /** @type string The model class name. **/ |
||
15 | private $_model; |
||
16 | |||
17 | /** @type array A map of keys from ScaleEngine's API to exposed model. **/ |
||
18 | private $_keyMap; |
||
19 | |||
20 | /** |
||
21 | * Create the model factory for a specific type of model. |
||
22 | * |
||
23 | * @param string $model The full class name for the model to construct. |
||
24 | * @param array $keyMap A map of keys from ScaleEngine's API to exposed model. |
||
25 | */ |
||
26 | public function __construct($model, array $keyMap) |
||
31 | |||
32 | /** |
||
33 | * Create a Ticket model using the provided data. |
||
34 | * |
||
35 | * The data given will be parsed and any missing keys will result in |
||
36 | * failure. |
||
37 | * |
||
38 | * @param array $data The data to use to populate the model. |
||
39 | * @return \Guzzle\Service\Resource\Model The parsed model. |
||
40 | */ |
||
41 | public function create(array $data) |
||
46 | |||
47 | /** |
||
48 | * Parse the data given into correct types and changes keys based on the |
||
49 | * key map. |
||
50 | * |
||
51 | * @param array $data The ticket data to parse. |
||
52 | * @return array The data after being converted to the parsed form. |
||
53 | */ |
||
54 | abstract public function parseData(array $data); |
||
55 | |||
56 | /** |
||
57 | * Convert a date from ScaleEngine's format into a PHP DateTime. |
||
58 | * |
||
59 | * ScaleEngine uses an all-zeros response for null dates, and this will |
||
60 | * convert those into null itself. |
||
61 | * |
||
62 | * This also considers that ScaleEngine uses UTC for its timezone and makes |
||
63 | * sure that the time returned is correct considering that behavior. |
||
64 | * |
||
65 | * @param string $date The date as returned from ScaleEngine. |
||
66 | * @return DateTime The converted date/time object. |
||
67 | */ |
||
68 | public function convertDate($date) |
||
82 | } |
||
83 |