/**
  * Returns a large image.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @since 0.1.1 Fix bug with returning image.
  * @api
  * @param int $image The image number to get
  * @return Image|null The large image.
  */
 public function getLargeImage($image)
 {
     if ($this->getCountImages() == 0 || !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || InputValidator::isEmptyArrayKey($this->images[$image], "Large")) {
         return null;
     }
     return $this->images[$image]["Large"];
 }
Ejemplo n.º 2
0
 /**
  * This function sets the results per page to show.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @since 0.1.0 Use attribute unstatic.
  * @api
  * @param int $resultsPerPage The results per page to filter.
  * @return boolean True if setting the results per page works, false if not.
  */
 public function setResultsPerPage($resultsPerPage)
 {
     if (!InputValidator::isRangedInt($resultsPerPage, null, 100)) {
         return false;
     }
     $this->resultsPerPage = $resultsPerPage;
     return true;
 }
 /**
  * Basic function to return an image.
  *
  * @author David Pauli <*****@*****.**>
  * @param int $image The image number to get
  * @param String $type The type of the image.
  * @return Image|null The thumbnail image.
  * @since 0.1.2
  */
 private function getImage($image, $type)
 {
     if ($this->getCountImages() == 0 || !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || InputValidator::isEmptyArrayKey($this->images[$image], $type)) {
         $reason = $this->getCountImages() == 0 ? "noImages" : !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) ? "IDunknown" : "imageCorrupt";
         switch ($reason) {
             case "noImages":
                 $this->errorSet("PS-4");
                 Logger::warning("ep6\\ProductSlideshow\nThere are no slideshow images.");
                 break;
             case "IDunknown":
                 $this->errorSet("PS-5");
                 Logger::warning("ep6\\ProductSlideshow\nThe slideshow image number is unknown.");
                 break;
             case "imageCorrupt":
                 $this->errorSet("PS-6");
                 Logger::warning("ep6\\ProductSlideshow\nThe required slideshow image exists but is empty.");
                 break;
         }
         return null;
     }
     return $this->images[$image][$type];
 }
Ejemplo n.º 4
0
 /**
  * Change the time to wait with the next request.
  *
  * @author David Pauli <*****@*****.**>
  * @param int time The time in ms every reload needs to wait until get new information.
  * @return boolean True if the change works, false if not.
  * @since 0.1.1
  * @since 0.1.2 Throw warning with wrong parameters.
  * @since 0.1.2 Add error reporting.
  */
 public static function setRequestWaitTime($time)
 {
     self::errorReset();
     if (!InputValidator::isRangedInt($time, 0)) {
         Logger::warning("ep6\\RESTClient\nRequest time (" . $time . ") is not valid.");
         self::errorSet("RESTC-10");
         return false;
     }
     self::$NEXT_RESPONSE_WAIT_TIME = $time;
     return true;
 }
Ejemplo n.º 5
0
 /**
  * Change the time to wait with the next request.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.1
  * @param int time The time in ms every reload needs to wait until get new information.
  * @return boolean True if the change works, false if not.
  * @api
  */
 public static function setRequestWaitTime($time)
 {
     if (!InputValidator::isRangedInt($time, 0)) {
         return false;
     }
     self::$NEXT_RESPONSE_WAIT_TIME = $time;
     return true;
 }
 /**
  * @group utility
  */
 function testIsRangedInt()
 {
     $this->assertFalse(InputValidator::isRangedInt("Some String"));
     $this->assertTrue(InputValidator::isRangedInt(3));
     $this->assertFalse(InputValidator::isRangedInt(null));
     $this->assertFalse(InputValidator::isRangedInt(1.2));
     $this->assertTrue(InputValidator::isRangedInt(1, 0));
     $this->assertFalse(InputValidator::isRangedInt(1, 2));
     $this->assertTrue(InputValidator::isRangedInt(1, 0, 12));
     $this->assertFalse(InputValidator::isRangedInt(1, 2, 12));
     $this->assertTrue(InputValidator::isRangedInt(1, null, 12));
     $this->assertFalse(InputValidator::isRangedInt(1, null, -1));
 }
Ejemplo n.º 7
0
 /**
  * Returns the search keyword.
  *
  * @author David Pauli <*****@*****.**>
  * @return String Gets a specific search keyword,, starting with 1.
  * @param int $number The number of the search keyword which is required.
  * @since 0.1.2
  * @since 0.1.3 Add reload feature.
  */
 public function getSearchKeyword($number)
 {
     self::errorReset();
     $this->reload();
     if (!InputValidator::isRangedInt($number, 1, $this->getNumberOfSearchKeywords())) {
         self::errorSet("P-9");
         return;
     }
     return $this->searchKeywords[$number - 1];
 }
Ejemplo n.º 8
0
 /**
  * This function sets the results per page to show.
  *
  * @author David Pauli <*****@*****.**>
  * @param int $resultsPerPage The results per page to filter.
  * @return boolean True if setting the results per page works, false if not.
  * @since 0.0.0
  * @since 0.1.0 Use attribute unstatic.
  * @since 0.1.2 Add error reporting.
  */
 public function setResultsPerPage($resultsPerPage)
 {
     $this->errorReset();
     if (!InputValidator::isRangedInt($resultsPerPage, null, 100)) {
         $this->errorSet("PF-4");
         Logger::warning("ep6\\ProductFilter\\The number " . $resultsPerPage . " as a product filter results per page needs to be lower than 100.");
         return false;
     }
     $this->resultsPerPage = $resultsPerPage;
     return true;
 }