/**
  * Returns the quantity unit.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @api
  * @param String $locale The localization.
  * @return String Gets the quantity unit.
  */
 public function getQuantityUnit($locale)
 {
     if (!InputValidator::isLocale($locale)) {
         return;
     }
     return !InputValidator::isEmptyArrayKey($this->quantityUnit, $locale) ? $this->quantityUnit[$locale] : null;
 }
Пример #2
0
 /**
  * This send function sends a special command to the REST server.
  *
  * @author David Pauli <*****@*****.**>
  * @param String command The path which is requested in the REST client.
  * @param String locale The localization to get.
  * @param mixed[] postfields Add specific parameters to the REST server.
  * @return String The returned JSON object or null if something goes wrong.
  * @since 0.0.0
  * @since 0.1.2 Throw warning with wrong parameters.
  * @since 0.1.2 Add error reporting.
  */
 public static function sendWithLocalization($command, $locale, $postfields = array())
 {
     self::errorReset();
     // check parameters
     if (!InputValidator::isLocale($locale)) {
         Logger::warning("ep6\\RESTClient\nLocale (" . $locale . ") is not valid.");
         self::errorSet("RESTC-3");
         return null;
     }
     return self::send($command . "?locale=" . $locale, $postfields);
 }
Пример #3
0
 /**
  * This send function sends a special command to the REST server.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @api
  * @param String command The path which is requested in the REST client.
  * @param String locale The localization to get.
  * @param mixed[] postfields Add specific parameters to the REST server.
  * @return String The returned JSON object or null if something goes wrong.
  */
 public static function sendWithLocalization($command, $locale, $postfields = array())
 {
     // cheeck parameters
     if (!InputValidator::isLocale($locale)) {
         return null;
     }
     return self::send($command . "?locale=" . $locale, $postfields);
 }
 /**
  * @group utility
  */
 function testIsLocale()
 {
     $this->assertFalse(InputValidator::isLocale("Some String"));
     $this->assertFalse(InputValidator::isLocale(3));
     $this->assertFalse(InputValidator::isLocale(null));
     $this->assertFalse(InputValidator::isLocale(1.2));
     $this->assertFalse(InputValidator::isLocale("a_b"));
     $this->assertFalse(InputValidator::isLocale("AB_de"));
     $this->assertFalse(InputValidator::isLocale("dedede_DEDEDE"));
     $this->assertTrue(InputValidator::isLocale("de_DE"));
     $this->assertTrue(InputValidator::isLocale("abc_DE"));
 }
Пример #5
0
 /**
  * This send function sends a special command to the REST server.
  *
  * @param String	command	The path which is requested in the REST client.
  * @param String	locale	The localization to get.
  * @return String	The returned JSON object.
  */
 public static function sendWithLocalization($command, $locale)
 {
     if (!InputValidator::isRESTCommand($command) && !InputValidator::isLocale($locale)) {
         return null;
     }
     return self::sendWithParameter($command . "?locale=" . $locale);
 }