注册状态
@param $key
@param $value
@return mixed
@throws \Exception
171897
protected function setStatus($key, $value)
    {
        if (is_array($value) || is_object($value)) {
            throw new \Exception("状态机只能为简单数据");
        }
        if ($this->saveContext["@status"] == null) {
            $this->saveContext["@status"] = [$key => $value];
        } else {
            //如果存在了并且相等就pass
            if (isset($this->saveContext["@status"][$key]) && $this->saveContext["@status"][$key] == $value) {
                return;
            }
            $this->saveContext->getData()["@status"][$key] = $value;
            //二维数组需要自己手动调用save
            $this->saveContext->save();
        }

        $this->registStatusHandle($key, $value);
    }
477147
protected function parseDateTime($value, $key)
    {
        // 获取时间字段类型
        $type = $this->query->getTableInfo('', 'type');
        if (isset($type[$key])) {
            $value = strtotime($value) ?: $value;
            if (preg_match('/(datetime|timestamp)/is', $type[$key])) {
                // 日期及时间戳类型
                $value = date('Y-m-d H:i:s', $value);
            } elseif (preg_match('/(date)/is', $type[$key])) {
                // 日期及时间戳类型
                $value = date('Y-m-d', $value);
            }
        }
        return $value;
    }
1072971
public static function set($key, $value = null)
    {
        if (is_array($key)) {
            static::$lang = array_merge(static::$lang, array_change_key_case($key));
        } else {
            $key = strtolower($key);

            if (!strpos($key, '.')) {
                static::$lang[$key] = $value;
                return null;
            }

            // 多维数组设置 A.B.C = 1
            $key = explode('.', $key);
            $tmp = null;
            foreach ($key as $k) {
                if (is_null($tmp)) {
                    if (isset(static::$lang[$k]) === false) {
                        static::$lang[$k] = [];
                    }
                    $tmp = &static::$lang[$k];
                } else {
                    is_array($tmp) || $tmp = [];
                    isset($tmp[$k]) || $tmp[$k] = [];
                    $tmp = &$tmp[$k];
                }
            }
            $tmp = $value;
            unset($tmp);
        }
        return null;
    }
796132
public function temp($key, $value = null)
    {
        if (null === $value) {
            if (isset($this->temp[$key])) {
                return $this->temp[$key];
            } else {
                return null;
            }
        } else {
            $this->temp[$key] = $value;
            return $value;
        }
    }
276456
public function query($key, $value = null)
    {
        if ($value) {
            return $this->replicate(['query' => [$key => $value]]);
        }

        return $this->replicate(['query' => $key]);
    }
809101
public function grammarExpression($key, $value)
    {
        if ($key === '!or' || $key === '!and') {
            if (!is_array($value)) {
                throw new Exception('[Norm/MongoCursor] "!or" and "!and" must have value as array.');
            }

            $newValue = array();

            foreach ($value as $v) {
                $newValue[] = $this->translateCriteria($v, true);
            }

            return array('$'.substr($key, 1), $newValue);
        }

        $splitted = explode('!', $key, 2);

        $field = $splitted[0];

        $schema = $this->collection->schema($field);

        if (strlen($field) > 0 && $field[0] === '$') {
            $field = '_'.substr($field, 1);
        }

        $operator = '$eq';
        $multiValue = false;

        if (isset($splitted[1])) {
            switch ($splitted[1]) {
                case 'like':
                    return array($field, array('$regex' => new \MongoRegex("/$value/i")));
                case 'regex':
                    return array($field, array('$regex' => new \MongoRegex($value)));
                case 'in':
                case 'nin':
                    $operator = '$'.$splitted[1];
                    $multiValue = true;
                    break;
                default:
                    $operator = '$'.$splitted[1];
                    break;
            }
        }

        if ($field === '_id') {
            if ($operator === '$eq') {
                return array($field, new MongoId($value));
            } else {
                return array($field, array($operator => new MongoId($value)));
            }
        }

        if (isset($schema)) {
            if ($multiValue) {
                if (!empty($value)) {
                    $newValue = array();
                    
                    if(!is_array($value)){
                        $value = array($value);
                    }

                    foreach ($value as $k => $v) {
                        // TODO ini quickfix buat query norm array seperti mongo
                        // kalau ada yang lebih bagus caranya bisa dibenerin
                        if (!$schema instanceof \Norm\Schema\NormArray) {
                            $newValue[] = $schema->prepare($v);
                        }
                    }
                    $value = $newValue;
                } else {
                    $value = array();
                }
            } else {
                // TODO ini quickfix buat query norm array seperti mongo
                // kalau ada yang lebih bagus caranya bisa dibenerin
                if (!$schema instanceof \Norm\Schema\NormArray) {
                    $value = $schema->prepare($value);
                }
            }

        }
        $value = $this->connection->marshall($value);

        if ($operator === '$eq') {
            return array($field, $value);
        } else {
            return array($field, array($operator => $value));
        }
    }
1095065
public function transform($key, $value)
  {
    if (in_array($key, $this->except)) {
      return $value;
    }

    return is_string($value) ? trim($value) : $value;
  }
1190048
public function set($key, $value = null)
    {
        if (!$this->id) {
            throw new Exception('Cannot use set without active session.');
        }
        if (is_array($key)) {
            foreach ($key as $k => $value) {
                $this->data[$k] = $value;
            }
        } else {
            $this->data[$key] = $value;
        }
        return true;
    }
56812
public function getValue($key = null)
    {
        if (is_null($key)) {//返回所有
            return $this->args;
        } elseif (isset($this->args[$key])) {
            return $this->args[$key];
        } else {
            return null;
        }
    }
164169
public function get($key, $value = null)
    {
        return $this->queryBag->key($key, $value, true);
    }
736848
public function setValue(string $key, $value): void
    {
        if (isset($this->orgData[$key])) {
            if (isset($this->removeAttributes[$key])) {
                // 已经被删除
                unset($this->removeAttributes[$key]);
            }
            if ($this->orgData[$key] != $value) {
                $this->updateAttributes[$key] = $value;
            }elseif (isset($this->updateAttributes[$key])){
                unset($this->updateAttributes[$key]);
            }
        } else {
            $this->addAttributes[$key] = $value;
        }
    }
300679
public function set($key, $value = null)
    {
        if (isset($value)) {
            return $this->array[$key] = $value;
        }

        return $this->array[] = $key;
    }
383269
public function set($key, $value)
    {
        $cont = clone $this;
        $cont->setParameter($key, $value);

        return $cont;
    }
694330
public function add($key, $value){
        if( $this->exists($key) ){
            throw new Exception("Item already exists in storage ($key)  ($this->name)");
        }
        $this->storage[$key] = $value;
        return $this->storage[$key];

    }
61883
public function add ($key , $value) {
        if (!$this->_r) {
            if ($key === null)
                $this->_d[] = $value;
            else
                $this->_d[$key] = $value;
        } else
            throw new Exception(Yii::t ('yii' , 'The map is read only.'));
    }
749750
private function fetchValueForKey($key, $value)
    {
        if (in_array($key, $this->getDates())) {
            return trim($value) === '' ? null : $value;
        }

        if (! $this->hasSetMutator($key)) {
            $value = $this->getAttribute($key);
        }

        if ($this->isJsonCastable($key) && ! is_null($value)) {
            $value = is_string($value) ? $this->getJsonCastValue($value) : $value;
        }

        return $value;
    }
716627
public function getset($key, $value)
    {
        $this->init();
        $result = $this->driver->getset($key, $value);
        return $this->convertFalseToNull($result);
    }