for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpUnitGen\Model\PropertyTrait;
use Doctrine\Common\Collections\Collection;
use PhpUnitGen\Model\ModelInterface\FunctionModelInterface;
/**
* Trait ClassLikeTrait.
*
* @author Paul Thébaud <[email protected]>.
* @copyright 2017-2018 Paul Thébaud <[email protected]>.
* @license https://opensource.org/licenses/MIT The MIT license.
* @link https://github.com/paul-thebaud/phpunit-generator
* @since Class available since Release 2.0.0.
*/
trait ClassLikeTrait
{
* @var FunctionModelInterface[]|Collection $functions Class functions.
protected $functions;
* @param FunctionModelInterface $function The function to add on this parent.
public function addFunction(FunctionModelInterface $function): void
$this->functions->add($function);
}
* @return FunctionModelInterface[]|Collection All the functions contained in this parent.
public function getFunctions(): Collection
return $this->functions;
* Check if a function exists.
* @param string $name The function name.
* @return bool True if it exists.
public function hasMethod(string $name): bool
return $this->functions->exists(function (FunctionModelInterface $function) use ($name) {
return $function->getName() === $name;
});
* @return int The number of testable (not abstract) function in this parent.
public function countNotAbstractFunctions(): int
return $this->functions->filter(function (FunctionModelInterface $function) {
return ! $function->isAbstract();
})->count();