处理一个数组项
@param $key int|string 键
@param $value string 值
@return string
487362
private function item($key, string $value): string
    {
        // 整型,表示不用关注 数组的键了.
        if (is_int($key)) {
            list($key, $value) = $this->itemWithoutKey($value);
        }

        // 去多余的空格
        $key = trim($key);
        $value = trim($value);

        // 如果 字段和方向的顺序写反了,翻过来
        if (strtoupper($key) == 'ASC' or strtoupper($key) == 'DESC') {
            list($key, $value) = [$value, $key];
        }

        // 已经确定了字段和方向
        $field = $key;
        $dim = strtoupper($value);

        // 排序中的方向不被允许
        if ($dim != 'ASC' and $dim != 'DESC') {
            trigger_error('排序方向只能使用ASC或DESC:'.$dim,E_USER_ERROR);
        }

        // 构造SQL中排序语法: 空格分隔
        if ($this->isField($field)) {
            $field = $this->markField($field);
        }

        return $field . ' ' . $dim;
    }
873103
public function nullIfEmpty($value, $key = null)
    {
        if (! is_null($key)) {
            $value = $this->fetchValueForKey($key, $value);
        }

        if (is_array($value)) {
            return $this->nullIfEmptyArray($key, $value);
        }

        if (is_bool($value)) {
            return $value;
        }

        return trim($value) === '' ? null : $value;
    }
262924
public function decode(string $value): ?int
    {
        $value = $this->hashids->decode($value);

        if (is_array($value) && sizeof($value) > 0) {
            return $value[0];
        } else {
            return null;
        }
    }
60488
public function marshal($value)
    {
        if ($value === null || $value === '') {
            return null;
        }
        if (is_numeric($value)) {
            return (int)$value;
        }

        return null;
    }
504079
public function write($key, $value)
    {
        $key = $this->_key($key);

        if (!is_int($value)) {
            $value = serialize($value);
        }

        $duration = $this->_config['duration'];
        if ($duration === 0) {
            return $this->_Redis->set($key, $value);
        }

        return $this->_Redis->setEx($key, $duration, $value);
    }
392626
protected function writeValue($key, $value) {
		$data = $this->readData();
		$data[$key] = $this->encode($value);

		if ($this->writeData($data)) {
			return $value;
		}

		return false;
	}
1008516
public function set($key, $value)
    {
        switch ($key) {
            case 'quantity':
                $this->setCheckTypeInteger($value, $key);
            break;
            case 'price':
            case 'tax':
                $this->setCheckIsNumeric($value, $key);

                $value = (float) $value;
        }

        $this->data[$key] = $value;

        return $this->getId();
    }
751759
public function read(string $value, string $key = null)
    {
        // Checks if a key was given
        if (isset($key)) {

            // Any key could be use in the where clause
            $query = 'SELECT * FROM ' . $this->table . ' WHERE ' . $key . ' = ?';
        } else {
            // The id key would be use in the where clause
            $query = 'SELECT * FROM ' . $this->table . ' WHERE id = ?';
        }
        // Execute the select query, then returns the results
        return $this->database->result($query, [$value]);
    }
162398
public function hsetnx($hash, $key, $value)
    {
        return (int) $this->client->hsetnx($hash, $key, $value);
    }
966330
protected function getKeyValuePair($key, $value)
    {
        if (strpos($value, '"') !== false) {
            return ' ' . $key . '=\'' . $value . '\'';
        }
        return ' ' . $key . '="' . $value . '"';
    }
660932
private function getNumberOfParts($key, $value)
    {
        $parts = substr($value, strlen(self::VALUE_SPLIT));

        if (!ctype_digit($parts) || $parts > PHP_INT_MAX) {
            throw new \RuntimeException(
                'Number of parts in split value for key "'.$key.'" is invalid.'
            );
        }

        // We know it's an integer. Now also force
        // its data type to be an integer.
        return (int) $parts;
    }
339393
public function decrement($key, $value = 1)
    {
        $decrement = 0;
        if ($integer = $this->get($key)) {
            $decrement = $integer - $value;
            if ($decrement <= 0) {
                $decrement = 0;
            }
            $this->put($key, $decrement, 0);

            return $decrement;
        }

        $this->put($key, $decrement, 0);

        return $decrement;
    }
888949
public function removeByIndex( $key, $value ){
		$this->table->focusIndex( $key, $value );
		$number	= 0;
		$rows	= $this->table->get( FALSE );
		if( count( $rows ) ){
			$number = $this->table->delete();
			foreach( $rows as $row ){
				switch( $this->fetchMode ){
					case \PDO::FETCH_CLASS:
					case \PDO::FETCH_OBJ:
						$id	= $row->{$this->primaryKey};
						break;
					default:
						$id	= $row[$this->primaryKey];
				}
				$this->cache->remove( $this->cacheKey.$id );
			}
			$result	= TRUE;
		}
		$this->table->defocus();
		return $number;
	}
1239306
public function get($key, $value = null)
    {
        return $this->headerBag->key($key, $value, true);
    }
981601
private function parseScalar(string $key, $value): string
    {
        return sprintf('%s%s%s', $key, $this->delimiter, $value);
    }
971700
public function decrement($key, $value = 1)
    {
        if ($this->exists($key)) {
            return self::$redis->decrBy($key, $value);
        } else {
            $this->set($key, -$value);

            return -$value;
        }
    }
352274
private function itemWithoutKey(string $value): array
    {
        $value = $this->formatSort($value);
        $arr = explode(' ', $value);

        // 每一项排序依据最多是二项,(列名+升降)
        if (count($arr) > 2) {
            trigger_error('指定排序的语法错误:' . json($arr), E_USER_ERROR);
        }

        // 只指明了一个值,默认升序
        if (count($arr) == 1) {
            $arr[1] = 'asc';
        }

        // 排序的字段和方向
        return $arr;
    }