@return string

@throws \UnexpectedValueException
428102
protected function buildWhere(): string
    {
        if ($this->query->getWhere() === null) {
            return '';
        }

        $where = $this->query->getWhere();
        if (count($where) !== 1) {
            throw new \UnexpectedValueException('Something went wrong: internal query property should always contain only one root element or bu null');
        }

        if (isset($where[LogicOp:: AND])) {
            $logicOp = LogicOp:: AND;
            $clauses = $where[LogicOp:: AND];
        } else {
            if (isset($where[LogicOp:: OR])) {
                $logicOp = LogicOp:: OR;
                $clauses = $where[LogicOp:: OR];
            } else {
                return false;
            }
        }

        return ' where ' . $this->buildClauses($logicOp, $clauses);
    }
398068
public function getResponse()
    {
        if(!$this->_response instanceof ControllerResponseInterface)
        {
            //Setup the response
            $this->_response->request = $this->getRequest();
            $this->_response->user    = $this->getUser();

            $this->_response = $this->getObject('lib:controller.response', ObjectConfig::unbox($this->_response));

            if(!$this->_response instanceof ControllerResponseInterface)
            {
                throw new \UnexpectedValueException(
                    'Response: '.get_class($this->_response).' does not implement ControllerResponseInterface'
                );
            }
        }

        return $this->_response;
    }
299775
public function getModel()
    {
        if(!$this->_model instanceof KModelInterface)
        {
            if(!($this->_model instanceof KObjectIdentifier)) {
                $this->setModel($this->_model);
            }

            $this->_model = $this->getObject($this->_model);

            if(!$this->_model instanceof KModelInterface)
            {
                throw new UnexpectedValueException(
                    'Model: '.get_class($this->_model).' does not implement KModelInterface'
                );
            }
        }

        return $this->_model;
    }
1062602
public function sqlFrom()
    {
        if (!$this->hasTable()) {
            throw new UnexpectedValueException(
                'Can not get SQL FROM clause. No table defined.'
            );
        }

        $table = $this->table();
        return '`'.$table.'` AS `'.self::DEFAULT_TABLE_ALIAS.'`';
    }
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;
    }
1142762
public function getHeader()
	{
		if (!$this->isAsync())
		{
			// Synchronous code is included only in the body
			return '';
		}

		if (!$this->getOption('code'))
		{
			throw new UnexpectedValueException('A Google Analytics tracking code is required.');
		}

		$code = $this->getOption('code');

		$output = '<script type="text/javascript">';
		$output .= 'var _gaq = _gaq || [];';
		$output .= "_gaq.push(['_setAccount', '{$code}']);";

		foreach ($this->listCalls() as $call)
		{
			$output .= $this->createCall($call['name'], $call['params']);
		}

		$output .= '_gaq.push(["_trackPageview"]);';
		$output .= '</script>';

		return $output;
	}
1311467
public function getCommandChain()
    {
        if(!$this->__command_chain instanceof CommandChainInterface)
        {
            $config = array('break_condition' => $this->getBreakCondition());
            $this->__command_chain = $this->getObject($this->__command_chain, $config);

            if(!$this->__command_chain instanceof CommandChainInterface)
            {
                throw new \UnexpectedValueException(
                    'CommandChain: '.get_class($this->__command_chain).' does not implement CommandChainInterface'
                );
            }
        }

        return $this->__command_chain;
    }
120875
public function getModel()
    {
        if(!$this->__model instanceof ModelInterface)
        {
            $this->__model = $this->getObject($this->__model);

            if(!$this->__model instanceof ModelInterface)
            {
                throw new \UnexpectedValueException(
                    'Model: '.get_class($this->__model).' does not implement ModelInterface'
                );
            }
        }

        return $this->__model;
    }
1349239
public function getUser()
    {
        if(!$this->_user instanceof KUserInterface)
        {
            $this->_user = $this->getObject($this->_user, array(
                'request' => $this->getRequest(),
            ));

            if(!$this->_user instanceof KUserInterface)
            {
                throw new UnexpectedValueException(
                    'User: '.get_class($this->_user).' does not implement KUserInterface'
                );
            }
        }

        return $this->_user;
    }
612150
public function transform($string)
    {
        $string = $this->transliterator->transliterate($string);
        if ($string === false) {
            throw new UnexpectedValueException($this->transliterator->getErrorMessage(), $this->transliterator->getErrorCode());
        }
        return $string;
    }
76741
public function value()
    {
        $value = lego_default($this->getOriginalValue(), $this->default);
        foreach ($this->pipes as $pipe) {
            $value = $pipe->handle($value, $this->data, $this);
        }

        return new HtmlString((string) $value);
    }
515492
protected function initContainer()
    {
        $container = $this->loadContainer(Configuration::projectDir() . $this->config['container']);

        if (!$container instanceof ContainerInterface) {
            throw new \UnexpectedValueException("Failed to get a container from '{$this->config['container']}'");
        }

        return $container;
    }
641179
protected function getUserUsername()
    {
        $attribute = Resolver::getLdapDiscoveryAttribute();

        $username = $this->user->getFirstAttribute($attribute);

        if (trim($username) == false) {
            throw new UnexpectedValueException(
                "Unable to locate a user without a {$attribute}"
            );
        }

        return $username;
    }
1364486
protected function getUserObjectGuid()
    {
        $guid = $this->user->getConvertedGuid();

        if (trim($guid) == false) {
            $attribute = $this->user->getSchema()->objectGuid();

            throw new UnexpectedValueException(
                "Unable to locate a user without a {$attribute}"
            );
        }

        return $guid;
    }
1006199
public function asVisibleString(): Primitive\VisibleString
    {
        if (!$this->_element instanceof Primitive\VisibleString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_VISIBLE_STRING));
        }
        return $this->_element;
    }
35702
public function getModel()
    {
        if(!$this->_model instanceof KModelInterface)
        {
            //Make sure we have a model identifier
            if(!($this->_model instanceof KObjectIdentifier)) {
                $this->setModel($this->_model);
            }

            $this->_model = $this->getObject($this->_model);

            if(!$this->_model instanceof KModelInterface)
            {
                throw new UnexpectedValueException(
                    'Model: '.get_class($this->_model).' does not implement KModelInterface'
                );
            }

            //Inject the request into the model state
            $this->_model->setState($this->getRequest()->query->toArray());
        }

        return $this->_model;
    }
708291
public function getCatalogue()
    {
        if (!$this->__catalogue instanceof TranslatorCatalogueInterface)
        {
            if(!($this->__catalogue instanceof ObjectIdentifier)) {
                $this->setCatalogue($this->__catalogue);
            }

            $this->__catalogue = $this->getObject($this->__catalogue);
        }

        if(!$this->__catalogue instanceof TranslatorCatalogueInterface)
        {
            throw new \UnexpectedValueException(
                'Catalogue: '.get_class($this->__catalogue).' does not implement TranslatorCatalogueInterface'
            );
        }

        return $this->__catalogue;
    }