Beispiel #1
0
 public function __construct($imageFileName)
 {
     if ($this->isImageFileNameValid($imageFileName)) {
         $this->imageFileName = $imageFileName;
     } else {
         throw new \InvalidArgumentException(Debug::sprintf("Cannot create ImageUrl with parameter >%s<", $imageFileName));
     }
 }
Beispiel #2
0
 private function isInferior()
 {
     if (is_null($this->max)) {
         return true;
     }
     if ($this->userValue <= $this->max) {
         return true;
     } else {
         throw new \InvalidArgumentException(Debug::sprintf("Value <%s> should be inferior or equal to <%s>", $this->userValue, $this->max));
     }
 }
Beispiel #3
0
 private function addManufacturers()
 {
     $manufacturerMapper = new ManufacturerMapper($this->idPrefix, $this->bfVersion, $this->logger);
     foreach ($this->okManufacturersArray as $okManufacturer) {
         try {
             $bfManufacturer = $manufacturerMapper->map($okManufacturer);
             $this->xmlDocument->addNodeToParent($bfManufacturer, "ProductManufacturer");
         } catch (XmlItemMapperException $e) {
             ExceptionsHandler::logError($e, $this->logger);
             $this->logger->error(Debug::sprintf("Skipping following manufacturer : <%s>", $okManufacturer));
         }
     }
 }
Beispiel #4
0
 private function addOrdersStatuses()
 {
     $ordersStatusesMapper = new OrderStatusMapper($this->bfVersion, $this->orderShipCarrier, $this->orderShipMethod, $this->logger);
     foreach ($this->okOrderStatusesArray as $okOrderStatus) {
         try {
             $bfOrderStatus = $ordersStatusesMapper->map($okOrderStatus);
             $this->xmlDocument->addNodeToParent($bfOrderStatus, "BigFishOrderStatusUpdateFeed");
             $this->hasOrdersStatuses = true;
         } catch (XmlItemMapperException $e) {
             ExceptionsHandler::logError($e, $this->logger);
             $this->logger->error(Debug::sprintf("Skipping following order status : <%s>", $okOrderStatus));
         }
     }
 }
Beispiel #5
0
 private function addProductsUpdates()
 {
     $productUpdatesMapper = new ProductUpdateMapper($this->idPrefix, $this->bfVersion, $this->taxCategory, $this->viewAllowCategory, $this->logger);
     foreach ($this->okProductsUpdatesArray as $okProductUpdate) {
         try {
             $bfProduct = $productUpdatesMapper->map($okProductUpdate);
             $this->xmlDocument->addNodeToParent($bfProduct, "Products");
             $this->hasProductsUpdates = true;
         } catch (XmlItemMapperException $e) {
             ExceptionsHandler::logError($e, $this->logger);
             $this->logger->error(Debug::sprintf("Skipping following product update : <%s>", $okProductUpdate));
         }
     }
 }
 public function removeOrphans($okProductsArray)
 {
     $okProductsArrayWithoutOrphans = array();
     foreach ($okProductsArray as $okProduct) {
         $isValid = true;
         if (!$this->productManufacturerExists($okProduct)) {
             $isValid = false;
             $this->logger->error(Debug::sprintf("Product <%s> has unresolved Manufacturer <%s> dependency", $okProduct->sku, $okProduct->products_manufacturers_id));
         }
         if ($isValid) {
             $okProductsArrayWithoutOrphans[] = $okProduct;
         } else {
             $this->logger->error(Debug::sprintf("Removing product <%s> : <%s>", $okProduct->sku, $okProduct));
         }
     }
     return $okProductsArrayWithoutOrphans;
 }
Beispiel #7
0
 private function isDateValid()
 {
     $isDateValid = false;
     if ($this->userValue instanceof \DateTime) {
         $isDateValid = true;
     } elseif (!is_string($this->userValue)) {
         $isDateValid = false;
     } else {
         $dateFromFormat = \DateTime::createFromFormat($this->format, $this->userValue);
         $isDateValid = $dateFromFormat && $this->userValue === date($this->format, $dateFromFormat->getTimestamp());
     }
     if ($isDateValid) {
         return true;
     } else {
         throw new \InvalidArgumentException(Debug::sprintf("Invalid date <%s> with format <%s>", $this->userValue, $this->format));
     }
 }
Beispiel #8
0
 private function isInArray()
 {
     if (is_null($this->array)) {
         return true;
     }
     if (!is_array($this->array)) {
         return false;
     }
     if (in_array($this->userValue, $this->array)) {
         return true;
     } else {
         throw new \InvalidArgumentException(Debug::sprintf("Value <%s> should be in array <%s> ", $this->userValue, $this->array));
     }
 }
Beispiel #9
0
 private function checkIndex($element, $currentPropertyName, $propertyIndex)
 {
     if (!isset($element->{$currentPropertyName}[(int) $propertyIndex])) {
         throw new XmlItemMapperException(Debug::sprintf("<%s> index in hierarchy <%s> doesn't exists...", $currentPropertyName, implode("->", $this->elementHierarchy)));
     }
 }
Beispiel #10
0
 public function isScaleValid()
 {
     if (!isset($this->scale)) {
         return true;
     }
     if (strpos($this->userValue, ".") === false) {
         return true;
     }
     $partsOfUserValue = explode(".", $this->userValue);
     $decimalPartOfUserValue = $partsOfUserValue[1];
     $maxDecimalValue = pow(10, $this->scale);
     if ($decimalPartOfUserValue < $maxDecimalValue) {
         return true;
     } else {
         throw new \InvalidArgumentException(Debug::sprintf("Value <%s> should not have more than <%s> decimals", $this->userValue, $this->scale));
     }
 }