示例#1
0
 /**
  * Set Style value
  *
  * @param string $key
  * @param mixed $value
  * @return self
  */
 public function setStyleValue($key, $value)
 {
     $key = String::removeUnderscorePrefix($key);
     if ($key == 'indent' || $key == 'hanging') {
         $value = $value * 720;
     } elseif ($key == 'spacing') {
         $value += 240;
         // because line height of 1 matches 240 twips
     }
     return parent::setStyleValue($key, $value);
 }
示例#2
0
 /**
  * Test remove underscore prefix
  */
 public function testRemoveUnderscorePrefix()
 {
     $this->assertEquals('item', String::removeUnderscorePrefix('_item'));
 }
示例#3
0
 /**
  * Set style value template method
  *
  * Some child classes have their own specific overrides.
  * Backward compability check for versions < 0.10.0 which use underscore
  * prefix for their private properties.
  * Check if the set method is exists. Throws an exception?
  *
  * @param string $key
  * @param string $value
  * @return self
  */
 public function setStyleValue($key, $value)
 {
     if (isset($this->aliases[$key])) {
         $key = $this->aliases[$key];
     }
     $method = 'set' . String::removeUnderscorePrefix($key);
     if (method_exists($this, $method)) {
         $this->{$method}($value);
     }
     return $this;
 }
示例#4
0
 /**
  * Set Style value
  *
  * @param string $key
  * @param mixed $value
  */
 public function setStyleValue($key, $value)
 {
     $key = String::removeUnderscorePrefix($key);
     if ($key == 'indent' || $key == 'hanging') {
         $value = $value * 720;
     } elseif ($key == 'spacing') {
         $value += 240;
         // because line height of 1 matches 240 twips
     } elseif ($key === 'line-height') {
         $this->setLineHeight($value);
         return;
     }
     $method = 'set' . $key;
     if (method_exists($this, $method)) {
         $this->{$method}($value);
     }
 }