/** * @param Entity $item * @throws Exception */ public function addItem($item) { if (!$item instanceof CategoryEntity) { throw new Exception("Unexpected Entity"); } parent::addItem($item); }
public function addItem($item) { $class_name = get_class($item); $namespace = "MonkeyData\\EshopXmlFeedGenerator\\XmlGenerator\\Entities\\"; if (!in_array($class_name, array("{$namespace}CategoryIdEntity", "{$namespace}CategoryNameEntity", "{$namespace}CategoryLevelEntity"))) { throw new Exception("Unexpected Entity"); } parent::addItem($item); }
/** * @param Entity $item * @throws Exception */ public function addItem($item) { $class_name = strtolower(get_class($item)); if (strpos($class_name, "customer") === false) { throw new Exception("Unexpected Entity: class is '{$class_name}'"); } elseif ($item instanceof CustomerEntity) { throw new Exception("Unexpected Entity is CustomerEntity"); } parent::addItem($item); }