ActiveRecord\AbstractRelationship::__construct PHP Method

__construct() public method

Constructs a relationship.
public __construct ( array $options = [] ) : mixed
$options array Options for the relationship (see {@link valid_association_options})
return mixed
    public function __construct($options = array())
    {
        $this->attribute_name = $options[0];
        $this->options = $this->merge_association_options($options);
        $relationship = strtolower(denamespace(get_called_class()));
        if ($relationship === 'hasmany' || $relationship === 'hasandbelongstomany') {
            $this->poly_relationship = true;
        }
        if (isset($this->options['conditions']) && !is_array($this->options['conditions'])) {
            $this->options['conditions'] = array($this->options['conditions']);
        }
        if (isset($this->options['class'])) {
            $this->set_class_name($this->options['class']);
        } elseif (isset($this->options['class_name'])) {
            $this->set_class_name($this->options['class_name']);
        }
        $this->attribute_name = strtolower(Inflector::instance()->variablize($this->attribute_name));
        if (!$this->foreign_key && isset($this->options['foreign_key'])) {
            $this->foreign_key = is_array($this->options['foreign_key']) ? $this->options['foreign_key'] : array($this->options['foreign_key']);
        }
    }