for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/******************************************************************************
* An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
*
* Copyright (c) 2016 Richard Klees <[email protected]>
* This software is licensed under The MIT License. You should have received
* a copy of the license along with the code.
*/
namespace Lechimp\Dicto\Graph\Predicate;
use Lechimp\Dicto\Regexp;
use Lechimp\Dicto\Graph\Predicate;
use Lechimp\Dicto\Graph\Entity;
/**
* A predicate that is true if a property is equal to a given value.
class _PropertyEquals extends Predicate {
* @var string
protected $name;
protected $value;
public function __construct($name, $value) {
assert('is_string($name)');
assert('is_string($value)');
$this->name = $name;
$this->value = $value;
}
* @inheritdocs
public function _compile() {
$name = $this->name;
return function(Entity $e) use ($name) {
if (!$e->has_property($name)) {
return false;
return $this->name === $e->property($name);
};
public function compile_to_source(array &$custom_closures) {
$value = $this->value;
return
" \$value = \n".
" \$e->has_property(\"$name\")\n".
" && (\$e->property(\"$name\") === \"$value\");\n";
public function for_types(array $existing_types) {
return $existing_types;