1 | <?php |
||
37 | class LinkSubject extends AbstractProductSubject |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * The available link types. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $linkTypes = array(); |
||
46 | |||
47 | /** |
||
48 | * The mapping for the SKUs to the created entity IDs. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $skuEntityIdMapping = array(); |
||
53 | |||
54 | /** |
||
55 | * Intializes the previously loaded global data for exactly one variants. |
||
56 | * |
||
57 | * @return void |
||
58 | * @see \Importer\Csv\Actions\ProductImportAction::prepare() |
||
59 | */ |
||
60 | public function setUp() |
||
75 | |||
76 | /** |
||
77 | * Return the entity ID for the passed SKU. |
||
78 | * |
||
79 | * @param string $sku The SKU to return the entity ID for |
||
80 | * |
||
81 | * @return integer The mapped entity ID |
||
82 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
83 | */ |
||
84 | public function mapSkuToEntityId($sku) |
||
95 | |||
96 | /** |
||
97 | * Return the link type ID for the passed link type code. |
||
98 | * |
||
99 | * @param string $linkTypeCode The link type code to return the link type ID for |
||
100 | * |
||
101 | * @return integer The mapped link type ID |
||
102 | * @throws \Exception Is thrown if the link type code is not mapped yet |
||
103 | */ |
||
104 | public function mapLinkTypeCodeToLinkTypeId($linkTypeCode) |
||
115 | |||
116 | /** |
||
117 | * Persist's the passed product link data and return's the ID. |
||
118 | * |
||
119 | * @param array $productLink The product link data to persist |
||
120 | * |
||
121 | * @return string The ID of the persisted entity |
||
122 | */ |
||
123 | public function persistProductLink($productLink) |
||
127 | |||
128 | /** |
||
129 | * Persist's the passed product link attribute data and return's the ID. |
||
130 | * |
||
131 | * @param array $productLinkAttribute The product link attribute data to persist |
||
132 | * |
||
133 | * @return string The ID of the persisted entity |
||
134 | */ |
||
135 | public function persistProductLinkAttribute($productLinkAttribute) |
||
139 | |||
140 | /** |
||
141 | * Persist's the passed product link attribute decimal data. |
||
142 | * |
||
143 | * @param array $productLinkAttributeDecimal The product link attribute decimal data to persist |
||
144 | * |
||
145 | * @return void |
||
146 | */ |
||
147 | public function persistProductLinkAttributeDecimal($productLinkAttributeDecimal) |
||
151 | |||
152 | /** |
||
153 | * Persist's the passed product link attribute integer data. |
||
154 | * |
||
155 | * @param array $productLinkAttributeInt The product link attribute integer data to persist |
||
156 | * |
||
157 | * @return string The ID of the persisted entity |
||
158 | */ |
||
159 | public function persistProductLinkAttributeInt($productLinkAttributeInt) |
||
163 | |||
164 | /** |
||
165 | * Persist's the passed product link attribute varchar data. |
||
166 | * |
||
167 | * @param array $productLinkAttributeVarchar The product link attribute varchar data to persist |
||
168 | * |
||
169 | * @return string The ID of the persisted entity |
||
170 | */ |
||
171 | public function persistProductLinkAttributeVarchar($productLinkAttributeVarchar) |
||
175 | } |
||
176 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: