1<?php 2 3 4namespace ComboStrap; 5 6 7class ConditionalValue 8{ 9 10 const CANONICAL = "conditional"; 11 /** 12 * @var string 13 */ 14 private $value; 15 /** 16 * @var string 17 */ 18 private $breakpoint; 19 20 /** 21 * ConditionalValue constructor. 22 */ 23 public function __construct($value) 24 { 25 $array = explode("-", $value); 26 $sizeof = sizeof($array); 27 switch ($sizeof) { 28 case 0: 29 LogUtility::msg("There is no value in ($value)", LogUtility::LVL_MSG_ERROR, self::CANONICAL); 30 $this->breakpoint = ""; 31 $this->value = ""; 32 break; 33 case 1: 34 $this->breakpoint = ""; 35 $this->value = $array[0]; 36 break; 37 case 2: 38 $this->breakpoint = $array[0]; 39 $this->value = $array[1]; 40 break; 41 default: 42 LogUtility::msg("The screen conditional value ($value) should have only one separator character `-`", LogUtility::LVL_MSG_ERROR, self::CANONICAL); 43 $this->breakpoint = $array[$sizeof-2]; 44 $this->value = $array[$sizeof-1]; 45 break; 46 } 47 } 48 49 public static function createFrom($value) 50 { 51 return new ConditionalValue($value); 52 } 53 54 public function getBreakpoint() 55 { 56 return $this->breakpoint; 57 } 58 59 public function getValue() 60 { 61 return $this->value; 62 } 63 64 65} 66