Skip to content

Commit

Permalink
ValueAs are static method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Feb 12, 2014
1 parent a1aa777 commit 56357e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/Packaged/Helpers/ValueAs.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ValueAs
*
* @return bool
*/
public function bool($value, $default = false)
public static function bool($value, $default = false)
{
if($value === null)
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public function bool($value, $default = false)
*
* @return int
*/
public function int($value, $default = 0)
public static function int($value, $default = 0)
{
if($value === null)
{
Expand All @@ -61,7 +61,7 @@ public function int($value, $default = 0)
*
* @return float
*/
public function float($value, $default = 0.0)
public static function float($value, $default = 0.0)
{
if($value === null)
{
Expand All @@ -79,7 +79,7 @@ public function float($value, $default = 0.0)
*
* @return string
*/
public function string($value, $default = "")
public static function string($value, $default = "")
{
if($value === null)
{
Expand All @@ -99,7 +99,7 @@ public function string($value, $default = "")
*
* @return mixed|string
*/
public function normalisedString($value, $default = "")
public static function normalisedString($value, $default = "")
{
if($value === null)
{
Expand All @@ -124,7 +124,7 @@ public function normalisedString($value, $default = "")
*
* @return array
*/
public function arr($value, $default = [])
public static function arr($value, $default = [])
{
if($value === null)
{
Expand Down Expand Up @@ -167,7 +167,7 @@ public function arr($value, $default = [])
*
* @return null|object
*/
public function obj($value, $default = null)
public static function obj($value, $default = null)
{
if($value === null)
{
Expand Down
12 changes: 8 additions & 4 deletions tests/ValueAsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ class ValueAsTest extends PHPUnit_Framework_TestCase
*/
public function testExactConversions($method, $value, $default, $expect)
{
$subject = new \Packaged\Helpers\ValueAs();
$this->assertSame($expect, $subject->$method($value, $default));
$this->assertSame(
$expect,
\Packaged\Helpers\ValueAs::$method($value, $default)
);
}

/**
* @dataProvider matchProvider
*/
public function testEqualConversions($method, $value, $default, $expect)
{
$subject = new \Packaged\Helpers\ValueAs();
$this->assertEquals($expect, $subject->$method($value, $default));
$this->assertEquals(
$expect,
\Packaged\Helpers\ValueAs::$method($value, $default)
);
}

public function exactProvider()
Expand Down

0 comments on commit 56357e5

Please sign in to comment.