Skip to content

Commit

Permalink
Adding accessor methods for new type hints
Browse files Browse the repository at this point in the history
Signed-off-by: Nate Brunette <n@tebru.net>
  • Loading branch information
natebrunette committed Mar 22, 2016
1 parent 93bc708 commit 0cc566c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Model/ParameterModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,46 @@ public function isCallable()
return 'callable' === $this->typeHint;
}

/**
* If the typeHint is an int
*
* @return bool
*/
public function isInt()
{
return 'int' === $this->typeHint;
}

/**
* If the typeHint is a boolean
*
* @return bool
*/
public function isBool()
{
return 'bool' === $this->typeHint;
}

/**
* If the typeHint is a string
*
* @return bool
*/
public function isString()
{
return 'string' === $this->typeHint;
}

/**
* If the typeHint is a float
*
* @return bool
*/
public function isFloat()
{
return 'float' === $this->typeHint;
}

/**
* If the typeHint is a class
*
Expand Down
32 changes: 32 additions & 0 deletions tests/Unit/Model/ParameterModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,38 @@ public function testIsCallable()
$this->assertTrue($parameterModel->isCallable());
}

public function testIsInt()
{
$parameterModel = $this->getParamterModel();
$parameterModel->setTypeHint('int');

$this->assertTrue($parameterModel->isInt());
}

public function testIsBool()
{
$parameterModel = $this->getParamterModel();
$parameterModel->setTypeHint('bool');

$this->assertTrue($parameterModel->isBool());
}

public function testIsString()
{
$parameterModel = $this->getParamterModel();
$parameterModel->setTypeHint('string');

$this->assertTrue($parameterModel->isString());
}

public function testIsFloat()
{
$parameterModel = $this->getParamterModel();
$parameterModel->setTypeHint('float');

$this->assertTrue($parameterModel->isFloat());
}

public function testIsObject()
{
$parameterModel = $this->getParamterModel();
Expand Down

0 comments on commit 0cc566c

Please sign in to comment.