Check KEK size.

@param string $kek
@throws \UnexpectedValueException
@return self
346390
protected function _checkKEKSize(string $kek): self
    {
        $len = $this->_keySize();
        if (strlen($kek) != $len) {
            throw new \UnexpectedValueException("KEK size must be $len bytes.");
        }
        return $this;
    }
586014
public function resize($n)
    {
        return new self(function ($rng, $size) use ($n) {
            return $this->call($rng, $n);
        });
    }
155804
private function mem_check($props)
    {
        // image size is unknown, we can't calculate required memory
        if (!$props['width']) {
            return true;
        }

        // channels: CMYK - 4, RGB - 3
        $multip = ($props['channels'] ?: 3) + 1;

        // calculate image size in memory (in bytes)
        $size = $props['width'] * $props['height'] * $multip;
        return rcube_utils::mem_check($size);
    }
562193
protected function _scope($entity) {
		$scope = [];
		foreach ($this->_config['scope'] as $key => $value) {
			if (is_numeric($key)) {
				if (isset($entity, $value)) {
					$scope[$value] = $entity->$value;
				} else {
					$message = "The `{$value}` scope in not present in the entity.";
					throw new UnexpectedValueException($message);
				}
			} else {
				$scope[$key] = $value;
			}
		}
		return $scope;
	}
1148391
public function get($key)
    {
        $ret = $this->traverseTree($key);
        if(!is_scalar($ret))
        {
            throw new UnexpectedValueException("The {$key} configuration value is not scalar");
        }
        return $ret;
    }
194346
public function offsetSet($key, $newval)
    {
        if ($def = in_array($key, array_keys($this->keys))) {
            parent::offsetSet($key, $newval);
        } else {
            throw new UnexpectedValueException($key.' is not defined in metadata definition '.get_class($this).'.');
        }
    }
764814
public function removeSize($size)
    {
        $size = is_array($size) ? new Size($size[0], $size[1]) : $size;
        $key = "$size";

        if (isset($this->sizes[$key])) {
            unset($this->sizes[$key]);
        }

        if (isset($this->sizeUrls[$key])) {
            unset($this->sizeUrls[$key]);
        }

        return $this;
    }
888905
public function append($count)
    {
        $bufferLen = strlen($this->buffer);

        if ($bufferLen >= $count + $this->maxAhead) {
            return $bufferLen;
        }

        ($ahead = $this->readAhead)
            && ($delta = $bufferLen - $ahead) < 0
            && $count -= $delta;

        $read = fread($this->handle, $count);
        if ($read === false) {
            throw new UnexpectedValueException(sprintf('Can not deal with fread() errors.'));
        }

        if ($readLen = strlen($read)) {
            $this->buffer .= $read;
            $bufferLen += $readLen;
        }

        return $bufferLen;
    }
670788
public static function getBiggerValue(array $values, $returnKey = false)
    {
        $bigger = null;

        foreach ($values as $k => $value) {
            if ($bigger === null || $value['size'] > $values[$bigger]['size']) {
                $bigger = $k;
            }
        }

        if ($bigger !== null) {
            return $returnKey ? $bigger : $values[$bigger]['value'];
        }
    }
351782
private function getNewInstance(string $funcKey)
    {
        if (! isset($this->classMap[$funcKey])) {
            throw new \UnexpectedValueException('找不到类' . $funcKey . '的实例规则');
        }
        return call_user_func($this->classMap[$funcKey], $this);
    }
832056
public function getExceptionHandler()
    {
        if(!$this->__exception_handler instanceof KExceptionHandlerInterface)
        {
            $this->__exception_handler = $this->getObject($this->__exception_handler);

            if(!$this->__exception_handler instanceof KExceptionHandler)
            {
                throw new UnexpectedValueException(
                    'Exception Handler: '.get_class($this->__exception_handler).' does not implement KExceptionHandlerInterface'
                );
            }
        }

        return $this->__exception_handler;
    }
50911
public function offsetGet($offset)
    {
        switch ($offset) {
            case 'operator':
                return $this->getOperator();
                break;

            case 'leftSubTerm':
                return $this->getLeftSubTerm();
                break;

            case 'rightSubTerm':
                return $this->getRightSubTerm();
                break;

            default:
                throw new \UnexpectedValueException("Offset $offset does not exist.");
        }
    }
446102
protected function setDefault(array $constants)
    {
        if (!isset($constants[self::$defaultKey])) {
            throw new \UnexpectedValueException("No default enum set");
        }

        $this->default = $constants[self::$defaultKey];

        return $this;
    }
177790
public function setSize($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->size !== $v) {
            $this->size = $v;
            $this->modifiedColumns[CategoryTableMap::COL_SIZE] = true;
        }

        return $this;
    }
251083
public function remove($key)
    {
        if (!$this->offsetExists($key)) {
            throw new UnexpectedValueException(sprintf('Unknown key %s.', $key));
        }

        return $this->offsetUnset($key);
    }
924390
protected function addValue(int $offset) : self
    {
        $this->setValue($this->getValue() + $offset);
        return $this;
    }
137759
public function &__get($k)
    {
        if (!isset($this->realConn->{$k})) {
            return $dummy;
        }
        return $this->realConn->{$k};
    }