for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/
namespace Cycle\Schema\Definition;
use Cycle\Schema\Definition\Map\OptionMap;
use Cycle\Schema\Exception\RelationException;
final class Relation
{
/** @var OptionMap */
private $options;
/** @var string */
private $type;
private $target;
/** @var string|null */
private $inverse = null;
private $inverseType = null;
* Relation constructor.
public function __construct()
$this->options = new OptionMap();
}
* @return OptionMap
public function getOptions(): OptionMap
return $this->options;
* @param string $type
* @return Relation
public function setType(string $type): Relation
$this->type = $type;
return $this;
* @return string
public function getType(): string
if ($this->type === null) {
throw new RelationException("Relation type must be set");
return $this->type;
* @param string $target
public function setTarget(string $target): Relation
$this->target = $target;
public function getTarget(): string
if ($this->target === null) {
throw new RelationException("Relation target must be set");
return $this->target;
* @param string $into
* @param string $as
public function setInverse(string $into, string $as): Relation
$this->inverse = $into;
$this->inverseType = $as;
* @return bool
public function isInversed(): bool
return $this->inverse != null;
$this->inverse
null|string
null
!==
* @return string|null
public function getInverseName(): ?string
return $this->inverse;
public function getInverseType(): ?string
return $this->inverseType;