Exemplo n.º 1
0
 /**
  * Converts $value to required date-time format
  * @param int|string $value - int: unix timestamp | string: valid date/time/date-time string
  * @param string $format - resulting value format
  * @param string|int|bool $now - current unix timestamp or any valid strtotime() string
  * @return string
  */
 public static function formatDateTime($value, $format, $now = 'now')
 {
     if (is_string($value) && strtotime($value) != 0) {
         // convert string value to unix timestamp and then to required date format
         if (!is_string($now) && !is_int($now)) {
             $now = 'now';
         }
         if (strtolower($now) === 'now' || empty($now)) {
             $value = strtotime($value);
         } else {
             if (is_numeric($now)) {
                 $value = strtotime($value, $now);
             } else {
                 $value = strtotime($value, strtotime($now));
             }
         }
     }
     return ValidateValue::isInteger($value, false) ? date($format, $value) : null;
 }
Exemplo n.º 2
0
 /**
  * @param int $pngQuality
  * @return $this
  * @throws ImageVersionConfigException
  */
 public function setPngQuality($pngQuality)
 {
     if (!ValidateValue::isInteger($pngQuality, true) || $pngQuality <= 0 || $pngQuality > 9) {
         throw new ImageVersionConfigException('PNG image quality should be within 1 and 9');
     }
     $this->pngQuality = $pngQuality;
     return $this;
 }