for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Variable entity class file
*
* @package EBloodBank
* @subpackage Models
* @since 1.0
*/
namespace EBloodBank\Models;
use InvalidArgumentException;
use EBloodBank as EBB;
* Variable entity class
* @Entity(repositoryClass="EBloodBank\Models\VariableRepository")
* @Table(name="variable")
class Variable extends Entity
{
* @var string
* @Id
* @Column(type="string", name="variable_name")
protected $name;
* @Column(type="string", name="variable_value", nullable=true)
protected $value;
* @return bool
public function isExists()
$id = (int) $this->get('id');
return ! empty($id);
}
* @return mixed
* @static
public static function sanitize($key, $value)
switch ($key) {
case 'name':
$value = EBB\sanitizeTitle($value);
sanitizeTitle
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$value = /** @scrutinizer ignore-call */ EBB\sanitizeTitle($value);
break;
return $value;
* @throws \InvalidArgumentException
public static function validate($key, $value)
if (! is_string($value) || empty($value)) {
throw new InvalidArgumentException(__('Invalid variable name.'));
return true;