@param string $key
@param mixed  $val

@return ServerRequest
180567
public function withCookie($key, $val)
    {
        $this->cookieJar->set($key, $val);

        return $this->withCookieParams($this->cookieJar->all());
    }
1067202
public function addInfo($key, $val = null)
    {
        if (is_array($key)) {
            foreach ($key as $a => $b) {
                $this->addInfo($a, $b);
            }

            return $this;
        }

        $this->debug("Gathered info: $key=$val");
        $this->info[$key] = $val;

        return $this;
    }
1061784
function load($key,$val) {
		if ($found=$this->find($key,$val)) {
			$this->id=$found[0]->id;
			return $this->item=$found[0]->item;
		}
		$this->reset();
		return [];
	}
197853
public function add($key, $val) {
        if (!isset($this->_attrs[$key])) {
            $this->_attrs[$key] = [];
        }
        
        if (!strcasecmp($key, 'id')) {
            // value for `id` should be one only
            $this->_attrs[$key] = $val;
        } else {
            // else append it
            array_push($this->_attrs[$key], $val);
        }
        
        return $this;
    }
1277692
final public function config(string $key, $val) {
		if ($this->request_initted)
			return $this;
		switch ($key) {
			case 'home':
				$this->config_home($val);
				return $this;
			case 'host':
				$this->config_host($val);
				return $this;
			case 'shutdown':
				$this->auto_shutdown = (bool)$val;
				return $this;
			case 'logger':
				if ($val instanceof Logger) {
					self::$logger = $val;
					self::$logger->debug('Router: started.');
				}
				return $this;
		}
		self::$logger->warning(
			"Router: invalid configuration key: '$key'.");
		return $this;
	}
187358
public final function set ($key, $val)
    {
        if (in_array($key, $this->getColumn())) {
            $this->record->{$key} = $val;
            return true;
        }

        return false;
    }
729620
public function assign($key, $val = null)
    {
        if (is_array($key)) {
            $this->args = array_merge($this->args, $key);
        } else {
            $this->args[$key] = $val;
        }
        return $this;
    }
880997
public function add($key, $val)
    {
      if (is_array($key))
        foreach($key as $k)
          $this->data[$k] = $val;
      else
        if (is_array($val))
          $this->data[$key] = $val;
      else
        $this->data[$key] = (string) $val;
    }
769425
protected function button($key, $val)
    {
        $extra = [
            'type' => strtolower(__FUNCTION__),
        ];

        return $this->composeElement($key, $val, $extra);
    }
613157
protected function makePage($key, $val)
    {
        // Check if it's a divider
        if ($val === '-') {
            return (object) ['divider' => true];
        }

        // Create a new page
        $page = ['url' => $val, 'divider' => false];
        $page = array_merge($page, $this->makeIcon($key));

        // Check if this item is the currently selected one
        $page['active'] = false;
        if (strpos(URL::current(), parse_url($page['url'], PHP_URL_PATH))) {
            $page['active'] = true;
        }

        // Return the new page
        return (object) $page;
    }
929398
function offsetset($key,$val) {
		return Base::instance()->visible($this,$key)?
			($this->$key=$val):$this->set($key,$val);
	}
33819
protected function parseOrderField($query, $key, $val)
    {
        if (isset($val['sort'])) {
            $sort = $val['sort'];
            unset($val['sort']);
        } else {
            $sort = '';
        }

        $sort = strtoupper($sort);
        $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';

        $options = $query->getOptions();
        $bind    = $this->connection->getFieldsBind($options['table']);

        foreach ($val as $k => $item) {
            $val[$k] = $this->parseDataBind($query, $key, $item, $bind);
        }

        return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort;
    }
1046439
public function addSelectOption($key, $val)
    {
        if (!is_string($key)) {
            throw new InvalidArgumentException(
                'Setting key must be a string.'
            );
        }

        // Make sure default options are loaded.
        if ($this->selectOptions === null) {
            $this->selectOptions();
        }

        $this->selectOptions[$key] = $val;

        return $this;
    }
680430
protected function custom($key, $val)
    {
        $extra = [
            'value' => (isset($val['name'])) ? $val['name'] : $key,
        ];

        return $this->composeElement($key, $val, $extra);
    }
325008
public function server(string $key = null, $default = null)
    {
        if (is_null($key)) {
            return $this->getServerParams();
        }
        return $this->getServerParams()[$key] ?? $default;
    }
24655
public function setAttribute($key, $val)
    {
        if(is_null($val) && array_key_exists($key, $this->attributes))
            unset($this->attributes[$key]);
        else
            $this->attributes[$key] = $val;
    }
394017
public function setUrlParams($key = 'path', $val = '')
    {
        if (is_array($key)) {
            self::$urlParams = array_merge(self::$urlParams, $key);
        } else {
            self::$urlParams[$key] = $val;
        }
    }