/** * Cart constructor * * @param StorageInterface $store * @param IdentifierInterface $identifier */ public function __construct(StorageInterface $store, IdentifierInterface $identifier) { $this->store = $store; $this->identifier = $identifier; // Generate/retrieve identifier $this->id = $this->identifier->get(); // Restore the cart from a saved version if (method_exists($this->store, 'restore')) { $this->store->restore($this->id); } // Let our storage class know which cart we're talking about $this->store->setIdentifier($this->id); }
/** * @param IdentifierInterface $identifier * @return bool */ public function equals(IdentifierInterface $identifier) { return $this->getValue() === $identifier->getValue(); }
/** * @param IdentifierInterface $identifier * @return bool */ public function isMatch(IdentifierInterface $identifier) { return $this->primary === $identifier->getPrimary(); }