PHP method IS NOT case sensitive :)

This commit is contained in:
Ivan Lanin 2014-03-09 21:59:23 +07:00
parent c364490955
commit fa1663a2b1
4 changed files with 12 additions and 12 deletions

View File

@ -192,7 +192,7 @@ class PHPWord_Style_Font
*/
public function setStyleValue($key, $value)
{
$method = 'set' . ucwords(substr($key, 1));
$method = 'set' . substr($key, 1);
if (method_exists($this, $method)) {
$this->$method($value);
}

View File

@ -156,7 +156,7 @@ class PHPWord_Style_Paragraph
if ($key == '_spacing') {
$value += 240; // because line height of 1 matches 240 twips
}
$method = 'set' . ucwords(substr($key, 1));
$method = 'set' . substr($key, 1);
if (method_exists($this, $method)) {
$this->$method($value);
}

View File

@ -45,11 +45,11 @@ class PHPWord_Style_FontTest extends \PHPUnit_Framework_TestCase
'fgColor' => null,
);
foreach ($attributes as $key => $default) {
$method = 'get' . ucwords($key);
$get = "get{$key}";
$object->setStyleValue("_$key", null);
$this->assertEquals($default, $object->$method());
$this->assertEquals($default, $object->$get());
$object->setStyleValue("_$key", '');
$this->assertEquals($default, $object->$method());
$this->assertEquals($default, $object->$get());
}
}
@ -73,9 +73,9 @@ class PHPWord_Style_FontTest extends \PHPUnit_Framework_TestCase
'fgColor' => '999999',
);
foreach ($attributes as $key => $value) {
$method = 'get' . ucwords($key);
$get = "get{$key}";
$object->setStyleValue("_$key", $value);
$this->assertEquals($value, $object->$method());
$this->assertEquals($value, $object->$get());
}
}

View File

@ -29,11 +29,11 @@ class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
'pageBreakBefore' => false,
);
foreach ($attributes as $key => $default) {
$method = 'get' . ucwords($key);
$get = "get{$key}";
$object->setStyleValue("_$key", null);
$this->assertEquals($default, $object->$method());
$this->assertEquals($default, $object->$get());
$object->setStyleValue("_$key", '');
$this->assertEquals($default, $object->$method());
$this->assertEquals($default, $object->$get());
}
}
@ -59,7 +59,7 @@ class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
'pageBreakBefore' => true,
);
foreach ($attributes as $key => $value) {
$method = 'get' . ucwords($key);
$get = "get{$key}";
$object->setStyleValue("_$key", $value);
if ($key == 'align') {
if ($value == 'justify') {
@ -70,7 +70,7 @@ class PHPWord_Style_ParagraphTest extends \PHPUnit_Framework_TestCase
} elseif ($key == 'spacing') {
$value += 240;
}
$this->assertEquals($value, $object->$method());
$this->assertEquals($value, $object->$get());
}
}