/** * Create a preview image given a source image. * * @param string $src * @param string $dst * @return bool */ public static function preview($src, $dst, $options = array()) { if (!is_readable($src)) { return false; } if (Mime::mime($src) == 'application/pdf') { $src .= '[0]'; } $image = new static($src); $image->format('jpeg'); $image->scale(700, 700); return $image->save($dst); }
/** * Returns true this instance will happen within the specified interval * * @param string|int $timeInterval the numeric value with space then time type. * Example of valid types: 6 hours, 2 days, 1 minute. * @return bool */ public function isWithinNext($timeInterval) { $now = new static(); $interval = $now->copy()->modify('+' . $timeInterval); $thisTime = $this->format('U'); return $thisTime <= $interval->format('U') && $thisTime >= $now->format('U'); }
/** * @param int $y * @param int $m * @param bool $endOfDay * @return static */ public static function createEndOfMonth($y, $m, $endOfDay = false) { $dt = new static("{$y}-{$m}-01"); if ($endOfDay) { return new static($dt->format('Y-m-t 23:59:59')); } return new static($dt->format('Y-m-t 00:00:00')); }
public static function changeFormat($format) { static::$format = $format; }
/** * set the display format * @param string $format * @example {before} - text 'before', {difference} - number difference, {measure} - e.g. 'minutes', {ago} - text 'ago' */ public static function setFormat($format) { static::$format = $format; }
/** * Get current date * * @return string */ public function getDate() { return $this->date->format(static::$format); }
/** * @param static|string|null $dateTime * @param string $format * @return string */ public static function convertToFormat($dateTime, $format) { $dateTime = new static($dateTime); return $dateTime->format($format); }
public static function init() { static::$format = join(' ', array("{:name}", "11∆", "{:title}", "11∆", "{:description}", "6∆", "{:author}", "13∆", "{:link}")); }
/** * Encodes internal record buffer instances into raw strings. * * @param mixed $data handling raw data. */ public static function marshalize($data) { $marshalizing = new static(); return (string) $marshalizing->format($data); }
private function reset() { static::$mime = 'text/html'; static::$extension = 'html'; static::$view = 'debug'; static::$format = 'php'; }
/** * Creates a new distance from a value and symbol. * * @param double|string $value Value of the distance * @param string $symbol Symbol of the distance, e.g. m or km * * @return static */ public static function create($value, $symbol) { // Find the conversion factor to meters $factor = static::factorToMeters($symbol); // Ensure proper formatting of value and factor for bc math $value = number_format($value, static::$s, '.', ''); $factor = number_format($factor, static::$s, '.', ''); // Convert to meters $meters = bcmul($value, $factor, static::$s); // Create new distance. $dist = new static($meters); $dist->format(static::FORMAT_DEFAULT . $symbol); return $dist; }