1 | <?php |
||
17 | abstract class AuctionArrayMapDecorator implements AuctionInterface |
||
18 | { |
||
19 | |||
20 | protected $auction = null; |
||
21 | |||
22 | /** |
||
23 | * This function should return array of mappings (human readable key => Allegro WebAPI FID) |
||
24 | * @return array |
||
25 | */ |
||
26 | abstract protected function getMap(); |
||
27 | |||
28 | |||
29 | /** |
||
30 | * This function should return id of Allegro category related to concrete decorator class |
||
31 | * @return integer |
||
32 | */ |
||
33 | abstract protected function getIdCategory(); |
||
34 | |||
35 | |||
36 | 9 | public function __construct(AuctionInterface $auction) |
|
40 | |||
41 | |||
42 | /** |
||
43 | * Makes sure that if a concrete class represents specific category, category id passed in fields array is correct: |
||
44 | * - set it as default, if none was provided |
||
45 | * - throw an exception, if some other category id was provided in $fields |
||
46 | * @param array $fields (reference) fields array to check |
||
47 | */ |
||
48 | 6 | protected function forceCategory(array& $fields) |
|
66 | |||
67 | |||
68 | /** |
||
69 | * Remap field keys using given map |
||
70 | * @param array $array to remap |
||
71 | * @param array $map to remap with |
||
72 | * @return array remapped array |
||
73 | */ |
||
74 | 5 | protected function remap(array $array, array $map) |
|
86 | |||
87 | /** |
||
88 | * @see Radowoj\Yaah\Auction::fromArray() |
||
89 | * @param array $humanReadableArray with human readable keys |
||
90 | */ |
||
91 | 3 | public function fromArray(array $humanReadableArray) |
|
98 | |||
99 | |||
100 | /** |
||
101 | * @see Radowoj\Yaah\Auction::toArray() |
||
102 | * @return array with human readable keys |
||
103 | */ |
||
104 | 3 | public function toArray() |
|
112 | |||
113 | |||
114 | /** |
||
115 | * @see Radowoj\Yaah\Auction::toApiRepresentation() |
||
116 | */ |
||
117 | 1 | public function toApiRepresentation() |
|
121 | |||
122 | |||
123 | /** |
||
124 | * @see Radowoj\Yaah\Auction::fromApiRepresentation() |
||
125 | */ |
||
126 | 1 | public function fromApiRepresentation(array $fields) |
|
130 | |||
131 | |||
132 | /** |
||
133 | * @see Radowoj\Yaah\Auction::setPhotos() |
||
134 | */ |
||
135 | 1 | public function setPhotos(array $photos) |
|
139 | |||
140 | |||
141 | } |
||
142 |