Habari\Comment::__set PHP Method

__set() public method

Overrides QueryRecord __set to implement custom object properties
public __set ( string $name, mixed $value ) : mixed
$name string Name of property to set
$value mixed Value of the property
return mixed The set field value
    public function __set($name, $value)
    {
        switch ($name) {
            case 'status':
                $value = self::status($value);
                break;
            case 'date':
                if (!$value instanceof DateTime) {
                    $value = DateTime::create($value);
                }
                break;
            case 'post':
                if (is_int($value)) {
                    // a post ID was passed
                    $p = Post::get(array('id' => $value));
                    $this->post_id = $p->id;
                    $this->post_object = $p;
                } elseif (is_string($value)) {
                    // a post Slug was passed
                    $p = Post::get(array('slug' => $value));
                    $this->post_id = $p->id;
                    $this->post_object = $p;
                } elseif (is_object($value)) {
                    // a Post object was passed, so just use it directly
                    $this->post_id = $value->id;
                    $this->post_object = $value;
                }
                return $value;
        }
        return parent::__set($name, $value);
    }