protected function getComposerCommand()
    {
        static $command = null;

        if (null !== $command) {
            return $command;
        }

        // Detect local composer.phar.
        $pharFile = $this->projectPath . '/composer.phar';

        if (file_exists($pharFile)) {
            return $command = '/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off "' . $pharFile . '"';
        }

        // Detect local composer command
        $composerFile = $this->projectPath . '/composer';

        if (file_exists($composerFile)) {
            return $command = './composer';
        }

        // Detect global composer command.
        $process = new Process('hash composer');
        $process->run();
        $isSuccessful = $process->isSuccessful();

        unset($process);

        if ($isSuccessful) {
            return $command = 'composer';
        }

        return $command;
    }