| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Optml_Width |
| 5 |
*/ |
| 6 |
class Optml_Width extends Optml_Property_Type { |
| 7 |
|
| 8 |
/** |
| 9 |
* Width Property. |
| 10 |
* |
| 11 |
* @var mixed $width |
| 12 |
*/ |
| 13 |
private $width = 'auto'; |
| 14 |
|
| 15 |
/** |
| 16 |
* Optml_Width constructor. |
| 17 |
* |
| 18 |
* @param mixed $value Default value. |
| 19 |
*/ |
| 20 |
public function __construct( $value ) { |
| 21 |
$this->set( $value ); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Set property value. |
| 26 |
* |
| 27 |
* @param mixed $value Value to set. |
| 28 |
*/ |
| 29 |
public function set( $value ) { |
| 30 |
|
| 31 |
if ( $value === 'auto' ) { |
| 32 |
$this->width = 'auto'; |
| 33 |
|
| 34 |
return; |
| 35 |
} |
| 36 |
if ( ! $this->is_valid_numeric( $value ) ) { |
| 37 |
$this->width = 'auto'; |
| 38 |
|
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
$this->width = $this->to_positive_integer( $value ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Return property value. |
| 47 |
* |
| 48 |
* @return mixed |
| 49 |
*/ |
| 50 |
public function get() { |
| 51 |
return $this->width; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Return ImageProxy URL formatted string property. |
| 56 |
* |
| 57 |
* @return mixed |
| 58 |
*/ |
| 59 |
public function toString() { |
| 60 |
return sprintf( 'w:%s', $this->width ); |
| 61 |
} |
| 62 |
} |
| 63 |
|