@throws LogicException

@return array
485817
public function getContentJson()
    {
        $content = $this->getContent();

        // Remove unwanted utf8 BOM
        if(substr($content, 0, 3) == pack('CCC', 239, 187, 191)) {
            $content = substr($content, 3);
        }

        $json = json_decode($content, true);
        if (null === $json) {
            throw new LogicException("Response content is not valid json: \n\n".$content);
        }

        return $json;
    }
1352117
public function getContext()
    {
        if (!$this->locked) {
            throw new Exception\LogicException(
                'Context is not yet available. You must first call handleRequest()'
            );
        }

        if (null === $this->context) {
            $this->context = new Context\Context();
            $this->context
                ->setVisibleColumns(array_keys($this->columns))
                ->setMaxPerPage($this->config->getPerPageChoices()[0]);
        }

        return $this->context;
    }
97289
public function toArray(): array
    {
        $type = $this->getType();

        if (empty($type)) {
            throw new InvalidException('Type has to be set');
        }

        return [$type->getName() => $this->_mapping];
    }
256093
public function insert()
    {
        if( !$this->tableName ) {
            throw new LogicException('No table name specified');
        }
        return $this->database->insert()
                ->table($this->tableName);
    }
958427
public function getObject()
    {
        if ($this->sourceObject === null && $this->isSourceObjectResolved === false) {
            $this->isSourceObjectResolved = true;

            try {
                $model = $this->modelFactory()->create($this->objectType())->load($this->objectId());
                if ($model->id()) {
                    $this->sourceObject = $model;
                }
            } catch (Exception $e) {
                throw new LogicException(sprintf(
                    'Could not load the source object of the relationship: %s',
                    $e->getMessage()
                ), 0, $e);
            }
        }

        return $this->sourceObject;
    }
1335645
protected function pushValues()
    {
        if( empty($this->values) ) {
            throw new LogicException('No values specified');
        }
        foreach( $this->values as $key => $value ) {
            if( !is_int($key) ) {
                $this->parts[] = $this->quoteIdentifierIfNotExpression($key);
                $this->parts[] = '=';
            }
            if( $value instanceof Expression ) {
                $this->parts[] = (string) $value;
            } else if( !is_int($key) ) {
                $this->parts[] = '?';
                $this->params[] = $value;
            }
            $this->parts[] = ',';
        }
        array_pop($this->parts);
    }
1264415
public function getContent()
    {
        if (!($pathname = $this->getPathname())) {
            throw new \LogicException('No pathname was specified - maybe it came from DigiDoc web service?');
        }

        $level = error_reporting(0);
        $content = file_get_contents($pathname);
        error_reporting($level);

        if (false === $content) {
            $error = error_get_last();
            throw new RuntimeException($error['message']);
        }

        return $content;
    }
907482
public static function getDescriptions($function_name)
    {
        if (is_string($function_name))
            $reflection = new ReflectionFunction($function_name);
        elseif (is_array($function_name))
            $reflection = new ReflectionMethod($function_name[0], $function_name[1]);
        else
            throw new LogicException();

        $comment = $reflection->getDocComment();

        $lines = explode("\n", $comment);
        $obj = new self($lines);

        return array(trim($obj->short_desc), trim($obj->long_desc));
    }
1214116
public function extract()
    {
        $bank = BankInterchange\Models\Bank::getInstance([
            'code' => $this->bank_code,
        ]);

        if ($bank === null) {
            $message = "Extractor class for CNAB$this->config not found";
            throw new \LogicException($message);
        }

        $extractor_class = __NAMESPACE__ . "\\Extractors\\Cnab$this->cnab\\"
            . BankInterchange\Utils::toPascalCase($bank->name);

        return new $extractor_class($this);
    }
111917
public function getAggregate($params = [])
    {
        if ($this->getMultipipeline()) {
            $pipelines = [];
            foreach ($this->class as $name => $className) {
                if (!class_exists($className)) {
                    throw new \LogicException("Analytics class '" . $className . "' does not exist!");
                }
                $class = new $className();
                $class->setParams($params);
                $pipelines[$name] = $class->get();
            }
            return $pipelines;
        } else {
            $className = $this->class;
            if (!class_exists($className)) {
                throw new \LogicException("Analytics class '" . $className . "' does not exist!");
            }
            $class = new $className();
            $class->setParams($params);
            return $class->get();
        }
    }
1205522
public function resolve()
    {
        if (!$this->cached) {
            if (!($prev = $this->handler)) {
                throw new \LogicException('No handler has been specified');
            }

            foreach (array_reverse($this->stack) as $fn) {
                $prev = $fn[0]($prev);
            }

            $this->cached = $prev;
        }

        return $this->cached;
    }
1319035
public function data()
    {

        if( isset( $this->filePath ) ) {

            return file_get_contents( $this->filePath );

        } elseif( $this->oid ) {

            $pg = $this->oid->pg;
            $pg->query( new Query( 'BEGIN' ) );

            $handle = pg_lo_open( $pg->resource->get(), $this->oid->oid, 'r' );

            $result = '';
            while( ( $data = pg_lo_read( $handle ) ) ){
                $result .= $data;
            }

            pg_lo_close( $handle );

            $pg->query( new Query( 'COMMIT' ) );

            return $result;

        }

        throw \LogicException("Shouldn't ever get tripped");

    }
1185875
public function getParent()
    {
        if ($this->parentRelation === null && $this->isParentRelationResolved === false) {
            $this->isParentRelationResolved = true;

            try {
                $source = $this->getObject();
                if ($source instanceof AttachmentContainerInterface) {
                    $model = $this->modelFactory()->create(self::class)->loadFrom('attachment_id', $source->id());
                    if ($model->id()) {
                        $this->parentRelation = $model;
                    }
                }
            } catch (Exception $e) {
                throw new LogicException(sprintf(
                    'Could not load the parent relationship: %s',
                    $e->getMessage()
                ), 0, $e);
            }
        }

        return $this->parentRelation;
    }
290574
public function getState()
    {
        if (empty($this->state)) {
            throw new LogicException(
                sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'state')
            );
        }
        return $this->state;
    }
949197
private function getInjectionProviderParams(Argument $argument) : array
    {
        $param = $argument->get();
        $class = $param->getDeclaringClass();
        if (! $class instanceof \ReflectionClass) {
            throw new \LogicException; // @codeCoverageIgnore
        }
        $method = $param->getDeclaringFunction();
        $this->setQualifiers($method, $param);

        return [
            new Node\Arg(new Scalar\String_((string) $argument)),
            new Expr\Array_([
                new Expr\ArrayItem(new Scalar\String_($class->name)),
                new Expr\ArrayItem(new Scalar\String_($method->name)),
                new Expr\ArrayItem(new Scalar\String_($param->name))
            ])
        ];
    }
1032511
public function getDescription()
    {
        if (empty($this->description)) {
            throw new LogicException(
                sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'description')
            );
        }
        return $this->description;
    }
373695
public function get() {
        if( $this->value !== null ) return $this->value;
        if( $this->error !== null ) throw $this->error;
        throw new \LogicException("Value and error cannot both be null");
    }