@param int $currentIdx

@throws EnvironmentException

@return string
345789
protected function findFileInFolders(int $currentIdx = 0): string
    {
        if ($currentIdx >= \count($this->folders)) {
            throw new EnvironmentException('Env file not found');
        }

        $filepath = $this->createFilepath($this->folders[$currentIdx], $this->filename);
        if (!\file_exists($filepath)) {
            ++$currentIdx;

            return $this->findFileInFolders($currentIdx);
        }

        if ($this->useCacheFile) {
            $this->cacheFile = $filepath . '.cache.php';
        }

        $this->currentFolder = $this->folders[$currentIdx];

        return $filepath;
    }
1149375
protected function getDevelopmentEnvironmentContent(Exception $ex, int $statusCode) : string
    {
        ob_start();

        if ($statusCode === 503) {
            require __DIR__ . "/templates/{$this->getRequestFormat()}/MaintenanceMode.php";
        } else {
            require __DIR__ . "/templates/{$this->getRequestFormat()}/DevelopmentException.php";
        }

        return ob_get_clean();
    }
571935
private function getTemporaryFile($postfix) {
        $sysFileName = tempnam(sys_get_temp_dir(), 'daux');
        if ($sysFileName === false) {
            throw new \RuntimeException("Could not create temporary file");
        }

        $newFileName = $sysFileName . $postfix;
        if ($sysFileName == $newFileName) {
            return $sysFileName;
        }

        if (DIRECTORY_SEPARATOR == '\\' ? rename($sysFileName, $newFileName) : link($sysFileName, $newFileName)) {
            return $newFileName;
        }

        throw new \RuntimeException("Could not create temporary file");
    }
1097763
public function getEnvironment()
    {
        $fileSystem = new Filesystem();
        $environment = '';
        $environmentPath = app()->getBasePath().'/.env';
        if ($fileSystem->isFile($environmentPath)) {
            $environment = trim($fileSystem->get($environmentPath));
            $envFile = app()->getBasePath().'/.'.$environment;

            if ($fileSystem->isFile($envFile.'.env')) {
                $dotEnv = new Dotenv(app()->getBasePath().'/', '.'.$environment.'.env');
                $dotEnv->load();
            }
        }

        return $environment;
    }
1204181
protected function getCurrentPlatform()
    {
        $env = [];

        $container = new Container('melisinstaller');
        if (isset($container['environments']) && isset($container['environments']['default_environment'])) {
            $env = $container['environments']['default_environment'];
        }

        return $env;
    }
833202
protected function getLastTagOnBranch($current_branch) {
    // List all tags, sort numerically, and filter out any that aren't numeric.
    $output = $this->taskExecStack()
      ->exec("git -c 'versionsort.suffix=-' tag --sort=-v:refname --merged $current_branch | sed '/^[[:alpha:]]/d'")
      ->interactive(FALSE)
      ->silent(TRUE)
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run()
      ->getMessage();
    $tags_on_branch = explode("\n", $output);
    $prev_tag = reset($tags_on_branch);

    return $prev_tag;
  }
941571
AtomicLong getCurrent(int pollerIndex) {
    rollCount(pollerIndex, clock.now());
    return data[2 * pollerIndex + CURRENT];
  }
286157
public function getAddIndexDDL(Index $index)
    {
        $pattern = "
CREATE %sINDEX %s ON %s (%s);
";

        return sprintf($pattern,
            $index->isUnique() ? 'UNIQUE ' : '',
            $this->quoteIdentifier($index->getName()),
            $this->quoteIdentifier($index->getTable()->getName()),
            $this->getColumnListDDL($index->getColumnObjects())
        );
    }
812095
public function current()
	{
		list($option, $values) = parent::current();
		
		if (isset($this->getAliasOptions()[ltrim($option, '-')]))
		{
			$option = $this->getAliasOptions()[ltrim($option, '-')];
		}
		
		$option = $option[0] == '-' ? $option : '-'.$option;
		
		if ($option == '-output')
		{
			return [];
		}
		
		$options = [];
		
		if ($option == '-map' || $option == '-metadata')
		{
			foreach ($option == '-metadata' ? array_merge(...$values) : $values as $key => $value)
			{
				$options[] = $option;
				$options[] = is_int($key) ? $value : sprintf('%s=%s', $key, $value);
			}
		}
		else if (stripos($option, 'filter') === 1)
		{
			// array_merge_recursive(...$values)
			$options[] = $option;
			$options[] = implode('; ', $values);
		}
		else if (($value = array_pop($values)) !== false)
		{
			$options[] = $option;
			
			if (is_scalar($value) && trim($value) != '' && $value !== true)
			{
				$options[] = $value;
			}
		}
		
		return $options;
	}
491931
public static function builtInFormatCode($pIndex)
    {
        // Clean parameter
        $pIndex = intval($pIndex);

        // Ensure built-in format codes are available
        self::fillBuiltInFormatCodes();

        // Lookup format code
        if (isset(self::$builtInFormats[$pIndex])) {
            return self::$builtInFormats[$pIndex];
        }

        return '';
    }
341362
protected function getCurrentPid()
    {
        if ($this->currentPid) {
            return $this->currentPid;
        }

        $path = $this->getPidPath();

        return $this->currentPid = file_exists($path)
            ? (int) file_get_contents($path) ?? $this->removePidFile()
            : null;
    }
539028
protected function server($idx, $throwException = true, $default = null) {
        if (!isset($_SERVER[$idx])) {
            if ($throwException) {
                throw new Exception("Required parameter was not received.");
            }
            return $default;
        }
        return (string) $_SERVER[$idx];
    }
484429
public function scalar($idx=0)
    {
        $row = $this->row();

        if(is_null($row))

            return NULL;

        $values = is_numeric($idx) ? array_values($row) : $row;

        return $values[$idx];
    }
562644
public function getCurrentType()
    {
        if (null !== $index = $this->getCurrencyIndex()) {
            return $index->getType();
        }

        $types = $this->repository->listIndexableEntityTypes();
        $type = array_shift($types);

        return $type;
    }
1219095
public function getDefaultEnvironmentId(array $environments)
    {
        // If there is only one environment, use that.
        if (count($environments) <= 1) {
            $environment = reset($environments);

            return $environment ? $environment->id : null;
        }

        // Check if there is only one "main" environment.
        $main = array_filter($environments, function (Environment $environment) {
            return $environment->is_main;
        });
        if (count($main) === 1) {
            $environment = reset($main);

            return $environment ? $environment->id : null;
        }

        // Check if there is a "master" environment.
        if (isset($environments['master'])) {
            return 'master';
        }

        return null;
    }
1122905
public function dumpSchema($environment)
    {
        $env = $this->getEnvironment($environment);
        $current = $env->getCurrentVersion();
        $codeGenerator = new CodeGenerator();
        $code = [
            '<?php',
            'use Samurai\\Samurai\\Component\\Migration\\Phinx\\Migration;',
            '',
            sprintf('class %s extends Migration', $this->migrationHelper->schemaClassNameStrategy($env->getOptions()['alias'])),
            '{',
            '    public function change()',
            '    {',
        ];

        $adapter = $env->getAdapter();

        foreach ($adapter->getTables() as $table) {
            if ($env->getSchemaTableName() === $table->getName()) continue;

            $code[] = sprintf('        $this->table("%s"%s)', $table->getName(), $codeGenerator->generateTableOptions($table));
            foreach ($table->getColumns() as $column) {
                if (! $codeGenerator->isSinglePrimaryKeyColumn($table, $column)) {
                    $code[] = sprintf('            ->addColumn("%s", "%s"%s)',
                                $column->getName(), $column->getType(), $codeGenerator->generateColumnOptions($column));
                }
            }
            foreach ($table->getDefinedIndexes() as $index) {
                $code[] = sprintf('            ->addIndex([%s])',
                            join(',', array_map(function($v) { return sprintf('"%s"', $v); }, $index['columns'])));
            }
            $code[] = '            ->create();';
        }

        $code = array_merge($code, [
            '    }',
            '}',
        ]);

        return join(PHP_EOL, $code);
    }
1201721
protected function fetchCurrentVersionUrl($currentVersionReference)
    {
        $versionResponse = $this->client->request(
            'GET',
            $currentVersionReference
        );

        if ($this->isErrorResponse($versionResponse)) {
            return $this->inputDispatcher->parse($versionResponse);
        }

        return $versionResponse->headers['Location'];
    }