1 | <?php |
||
35 | class EeMediaSubject extends MediaSubject |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * The mapping for the SKUs to the created entity IDs. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $skuRowIdMapping = array(); |
||
44 | |||
45 | /** |
||
46 | * Intializes the previously loaded global data for exactly one variants. |
||
47 | * |
||
48 | * @return void |
||
49 | * @see \Importer\Csv\Actions\ProductImportAction::prepare() |
||
50 | */ |
||
51 | 1 | public function setUp() |
|
66 | |||
67 | /** |
||
68 | * Load's the product media gallery value with the passed value/store/row ID. |
||
69 | * |
||
70 | * @param integer $valueId The value ID of the product media gallery value to load |
||
71 | * @param string $storeId The store ID of the product media gallery value to load |
||
72 | * @param string $rowId The row ID of the parent product of the product media gallery value to load |
||
73 | * |
||
74 | * @return array The product media gallery value |
||
75 | */ |
||
76 | public function loadProductMediaGalleryValueByValueIdAndStoreIdAndRowId($valueId, $storeId, $rowId) |
||
80 | |||
81 | /** |
||
82 | * Load's the product media gallery with the passed value/entity ID. |
||
83 | * |
||
84 | * @param integer $valueId The value ID of the product media gallery value to entity to load |
||
85 | * @param integer $rowId The row ID of the product media gallery value to entity to load |
||
86 | * |
||
87 | * @return array The product media gallery |
||
88 | */ |
||
89 | public function loadProductMediaGalleryValueToEntityByValueIdAndRowId($valueId, $rowId) |
||
93 | |||
94 | /** |
||
95 | * Return the row ID for the passed SKU. |
||
96 | * |
||
97 | * @param string $sku The SKU to return the row ID for |
||
98 | * |
||
99 | * @return integer The mapped row ID |
||
100 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
101 | */ |
||
102 | 1 | public function mapSkuToRowId($sku) |
|
113 | } |
||
114 |
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: