/** * translate from width and ratio to dimension * * @param int $width width of the rectangular dimension * @param float $factor a factor to determine height. * bool False to omit height * @param string $scale_model model of scaling property * @return rendered dimension */ public static function &fromWidth($width, $factor = FALSE, $scale_model = FALSE) { // validate parameter if (!self::isInt($width)) { throw new DimensionError('First parameter must be integer or integer string'); return NULL; } elseif ($factor !== FALSE && !is_numeric($factor)) { throw new DimensionError('Second parameter must be a number'); return NULL; } // render dimension $d = new Dimension(); $d->width = $width; if ($factor !== FALSE) { $d->height = Calc::rectHeight($width, $factor); } $d->factor = $factor; $d->scale_model = $scale_model; return $d; }