for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Moka\Stub;
use Moka\Exception\InvalidArgumentException;
/**
* Class AbstractStub
* @package Moka\Stub
*/
abstract class AbstractStub implements StubInterface
{
const REGEX_NAME = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/';
* @var string
protected $name;
* @var mixed
protected $value;
* AbstractStub constructor.
* @param string $name
* @param mixed $value
*
* @throws InvalidArgumentException
public function __construct(string $name, $value)
if (!preg_match(self::REGEX_NAME, $name)) {
throw new InvalidArgumentException(
sprintf(
'Name must be a valid variable or method name, "%s" given',
$name
)
);
}
$this->name = $name;
$this->value = $value;
* @return string
public function getName(): string
return $this->name;
* @return mixed
public function getValue()
return $this->value;