| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Optml_Height |
| 5 |
*/ |
| 6 |
class Optml_Height extends Optml_Property_Type { |
| 7 |
|
| 8 |
/** |
| 9 |
* Height Property. |
| 10 |
* |
| 11 |
* @var mixed $height |
| 12 |
*/ |
| 13 |
private $height = 'auto'; |
| 14 |
|
| 15 |
/** |
| 16 |
* Optml_Height 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 |
if ( $value === 'auto' ) { |
| 31 |
$this->height = 'auto'; |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
if ( ! $this->is_valid_numeric( $value ) ) { |
| 36 |
$this->height = 'auto'; |
| 37 |
return; |
| 38 |
} |
| 39 |
|
| 40 |
$this->height = $this->to_positive_integer( $value ); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Return property value. |
| 45 |
* |
| 46 |
* @return mixed |
| 47 |
*/ |
| 48 |
public function get() { |
| 49 |
return $this->height; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Return ImageProxy URL formatted string property. |
| 54 |
* |
| 55 |
* @return mixed |
| 56 |
*/ |
| 57 |
public function toString() { |
| 58 |
return sprintf( 'h:%s', $this->height ); |
| 59 |
} |
| 60 |
} |
| 61 |
|