@throws RuntimeException

@return MutableBag
551430
private function getPlatformUpdates()
    {
        /** @var ContainerHelper $helper */
        $helper = $this->getHelper('container');
        $app = $helper->getContainer();
        $platform = $app['db']->getDatabasePlatform();
        $platformName = $platform->getName();
        $schemaTables = $app['schema']->getSchemaTables();
        $tables = MutableBag::from([]);
        /** @var Table $table */
        foreach ($schemaTables as $table) {
            $tables[] = $table->getName();
        }

        if ($platformName === 'sqlite') {
            return MutableBag::from(['VACUUM', 'ANALYZE']);
        }

        if ($platformName === 'postgresql') {
            $updates = MutableBag::from(['VACUUM(FULL, ANALYZE)']);
            /** @var string $table */
            foreach ($tables as $table) {
                $updates[] = 'REINDEX TABLE ' . $table;
            }

            return $updates;
        }

        if ($platformName === 'mysql') {
            return MutableBag::from([
                'ANALYZE TABLE ' . $tables->join(', '),
                'OPTIMIZE TABLE ' . $tables->join(', '),
            ]);
        }

        throw new RuntimeException(sprintf('Unsupported platform: %s', $platformName));
    }
1306724
public function initialize()
    {
        if (null !== $this->collection) {
            return;
        }

        if (empty($this->dbOptions['database'])) {
            throw new \RuntimeException('The option "database" must be set');
        }
        if (empty($this->dbOptions['collection'])) {
            throw new \RuntimeException('The option "collection" must be set');
        }

        $this->collection = $this
            ->mongo
            ->selectDB($this->dbOptions['database'])
            ->selectCollection($this->dbOptions['collection']);
    }
1059606
protected function createFactory()
    {
        if (!class_exists($this->factoryClass)) {
            throw new RuntimeException(sprintf(
                'Failed to create an instance of non-existing factory class "%s".',
                $this->factoryClass
            ));
        }

        $class = $this->factoryClass;

        switch (count($this->args)) {
            case 0:
                $factory = new $class();
                break;

            case 1:
                $factory = new $class($this->args[0]);
                break;

            case 2:
                $factory = new $class($this->args[0], $this->args[1]);
                break;

            case 3:
                $factory = new $class($this->args[0], $this->args[1], $this->args[2]);
                break;

            case 4:
                $factory = new $class($this->args[0], $this->args[1], $this->args[2], $this->args[3]);
                break;

            default:
                $reflection = new ClassReflection($class);
                $factory = $reflection->newInstanceArgs($this->args);
                break;
        }

        if (!$factory instanceof FactoryInterface) {
            throw new LogicException(sprintf(
                'Invalid service factory. Factory is expected to be an instance of %s, %s given.',
                'Zend\ServiceManager\FactoryInterface',
                get_class($factory)
            ));
        }

        return $factory;
    }
22858
private function load()
    {
        if (file_exists(static::FILENAME)) {
            return MutableBag::from(Yaml::parse(file_get_contents(static::FILENAME)) ?: []);
        }

        return MutableBag::of();
    }
1254737
public function load() : Persistable
    {
        $data = $this->connector->get($this->key) ?: '';

        $persistable = $this->serializer->unserialize($data);

        if (!$persistable instanceof Persistable) {
            throw new RuntimeException('Persistable could not be'
                . ' reconstituted.');
        }

        return $persistable;
    }
1289449
public function propertyFactory()
    {
        if (!isset($this->propertyFactory)) {
            throw new RuntimeException(sprintf(
                'Property Factory is not defined for [%s]',
                get_class($this)
            ));
        }

        return $this->propertyFactory;
    }
394814
public static function runtime($context) {
        $class = new \ReflectionClass($context['runtime']);
        $ret = '';
        $methods = static::getClassMethods($context, $class);

        $exports = array_keys($context['usedCount']['runtime']);

        while (true) {
            if (array_sum(array_map(function ($name) use (&$exports, $methods) {
                $n = 0;
                foreach ($methods[$name][1] as $child => $count) {
                    if (!in_array($child, $exports)) {
                       $exports[] = $child;
                       $n++;
                    }
                }
                return $n;
            }, $exports)) == 0) {
                break;
            }
        }

        foreach ($exports as $export) {
            $ret .= ($methods[$export][0] . "\n");
        }

        return $ret;
    }
511228
public function getRuntimeConfigurableWrapper()
    {
        if ($this->wrapper === null) {
            $this->wrapper = new RuntimeConfigurable($this, $this->getTaskName());
        }

        return $this->wrapper;
    }
1039827
public function build()
    {
        if (is_null($this->selectFields)) {
            throw new RuntimeException('The `select()` function must be' .
                ' called prior to this function');
        }

        $awql = $this->buildSelectClause();
        $awql = $this->appendWhereClause($awql);
        $awql = $this->appendOrderByClause($awql);

        if (is_null($this->startIndex) && is_null($this->pageSize)) {
            return new ServiceQuery($awql);
        }
        return new ServiceQuery(
            $awql,
            $this->startIndex,
            $this->pageSize
        );
    }
684382
public function getBody()
    {
        if ($this->isAbstract() === true) {
            throw new RuntimeException('Can not get body of an abstract method');
        }

        $fileName = $this->getDeclaringClass()->getFileName();
        if ($fileName === false) {
            throw new RuntimeException('Can not get body of a method belonging to an internal class.');
        }

        $lines = file($fileName, FILE_IGNORE_NEW_LINES);
        $lines = array_slice($lines, $this->getStartLine() - 1, ($this->getEndLine() - $this->getStartLine() + 1),
            true);
        $lines = implode("\n", $lines);

        $firstBracketPos = strpos($lines, '{');
        $lastBracketPost = strrpos($lines, '}');
        $body = substr($lines, $firstBracketPos + 1, $lastBracketPost - $firstBracketPos - 1);

        return trim(rtrim($body), "\n\r");
    }
324225
private function getFilesbag()
    {
        static $filesBag = null;

        if (is_null($filesBag)) {
            $filesBag = new FileInput($this->files);
        }

        return $filesBag;
    }
31929
public static function bootMutable()
    {
        if (!isset(static::$attributeMutator)) {
            if (function_exists('app') && app()->bound('eloquence.mutator')) {
                static::setAttributeMutator(app('eloquence.mutator'));
            } else {
                static::setAttributeMutator(new Mutator);
            }
        }
        
        $hooks = new Hooks;

        foreach (['setAttribute', 'getAttribute', 'toArray'] as $method) {
            static::hook($method, $hooks->{$method}());
        }
    }
64498
public function getManualDb()
    {
        if (!isset($this->manualDb)) {
            $dbFile = $this->getManualDbFile();
            if (\is_file($dbFile)) {
                try {
                    $this->manualDb = new \PDO('sqlite:' . $dbFile);
                } catch (\PDOException $e) {
                    if ($e->getMessage() === 'could not find driver') {
                        throw new RuntimeException('SQLite PDO driver not found', 0, $e);
                    } else {
                        throw $e;
                    }
                }
            }
        }

        return $this->manualDb;
    }
244874
public function create()
    {
        $return = false;
        if (!$this->isExists()) {
            if (mkdir($this->getPathname(), 0777, true)) {
                $return = true;
            } else {
                throw new RuntimeException("Can't create " . $this->getPathname() . ' folder');
            }
        }

        return $return;
    }
1078735
public function save()
    {
        $path = $this->_buildParamsPath($this->alias);

        if (file_exists($path)) {
            chmod($path, 0644);
        }

        $params = '';

        foreach ($this->params as $key => $value) {
          $params .= $key.'='.$value."\n";
        }

        try {
          file_put_contents($path, $params);
        } catch (Exception $e) {
            throw new \RuntimeException($e->getMessage());
        }

        chmod($path, 0444);

        return $this;
    }
378259
public static function getInstance()
    {
        if (is_null(self::$instance)) {
            throw new \RuntimeException('You must first create the singleton instance with createInstance().');
        }
        self::$instance->setGlobalsFromSugar();
        self::$instance->chdirToSugarDir();

        return self::$instance;
    }
519243
protected function parse(string $file): MutableBag
    {
        $data = Yaml::parse(file_get_contents($file));

        return MutableBag::fromRecursive($data);
    }