×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
1
 
0
Language: PHP
Posted by: ic L…
Added: Nov 19, 2016 5:42 PM
Modified: Nov 20, 2016 8:05 PM
Views: 2138
  1.         public $width = '100%';
  2.         public function __set_Width($width)
  3.         {
  4.                 if (Strings::match($width, '~^calc\s?(.+);?$~i')) {
  5.                         $return = $width;
  6.                 } else {
  7.                         $return = Strings::replace($width, '~\s~i', '');
  8.                         $return = Strings::replace($return, '~,~', '.');
  9.                         $parts = Strings::match($return, '~^(\d+\.?\d*)(px|mm|cm|in|pt|pc|em|ex|ch|rem|%|vw|vh|vmin|vmax)?;?$~i');
  10.                         if (!$parts) {
  11.                                 $return = $this->_properties['width']; // použije se defaultní hodnota
  12.                         } else if (!isset($parts[2])) {
  13.                                 $return = $parts[1].'px';
  14.                         }
  15.                 }
  16.  
  17.                 $this->setProperty('width', $return); // něco jako return
  18.         }