public function add($key, $value)
    {
        if (!array_key_exists($key, $this->data)) {
            $this->data[$key] = $value;
        } elseif (is_array($this->data[$key])) {
            $this->data[$key][] = $value;
        } else {
            $this->data[$key] = [$this->data[$key], $value];
        }

        return $this;
    }
public function add($key, $value)
    {
        if (!array_key_exists($key, $this->data)) {
            $this->data[$key] = $value;
        } elseif (is_array($this->data[$key])) {
            $this->data[$key][] = $value;
        } else {
            $this->data[$key] = [$this->data[$key], $value];
        }

        return $this;
    }
public function add ( $ key , $ value ) { if ( ! array_key_exists ( $ key , $ this -> data ) ) { $ this -> data [ $ key ] = $ value ; } elseif ( is_array ( $ this -> data [ $ key ] ) ) { $ this -> data [ $ key ] [ ] = $ value ; } else { $ this -> data [ $ key ] = [ $ this -> data [ $ key ] , $ value ] ; } return $ this ; }
Add a value to a key.  If a key of the same name has already been added,
the key value will be converted into an array and the new value will be
pushed to the end of the array.

@param string $key   Key to add
@param mixed  $value Value to add to the key

@return Collection Returns a reference to the object.
Add a value to a key . If a key of the same name has already been added the key value will be converted into an array and the new value will be pushed to the end of the array .