From f6933b82bbdb767480abf4cf6818b2db56fae1cc Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Sat, 2 May 2015 15:54:22 +0200 Subject: Use composer to pull in propel and set it up --- .../Symfony/Component/Finder/Shell/Shell.php | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 Aufgabe06/vendor/symfony/finder/Symfony/Component/Finder/Shell/Shell.php (limited to 'Aufgabe06/vendor/symfony/finder/Symfony/Component/Finder/Shell/Shell.php') diff --git a/Aufgabe06/vendor/symfony/finder/Symfony/Component/Finder/Shell/Shell.php b/Aufgabe06/vendor/symfony/finder/Symfony/Component/Finder/Shell/Shell.php new file mode 100644 index 0000000..6d7bff3 --- /dev/null +++ b/Aufgabe06/vendor/symfony/finder/Symfony/Component/Finder/Shell/Shell.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Finder\Shell; + +/** + * @author Jean-François Simon + */ +class Shell +{ + const TYPE_UNIX = 1; + const TYPE_DARWIN = 2; + const TYPE_CYGWIN = 3; + const TYPE_WINDOWS = 4; + const TYPE_BSD = 5; + + /** + * @var string|null + */ + private $type; + + /** + * Returns guessed OS type. + * + * @return int + */ + public function getType() + { + if (null === $this->type) { + $this->type = $this->guessType(); + } + + return $this->type; + } + + /** + * Tests if a command is available. + * + * @param string $command + * + * @return bool + */ + public function testCommand($command) + { + if (!function_exists('exec')) { + return false; + } + + // todo: find a better way (command could not be available) + $testCommand = 'which '; + if (self::TYPE_WINDOWS === $this->type) { + $testCommand = 'where '; + } + + $command = escapeshellcmd($command); + + exec($testCommand.$command, $output, $code); + + return 0 === $code && count($output) > 0; + } + + /** + * Guesses OS type. + * + * @return int + */ + private function guessType() + { + $os = strtolower(PHP_OS); + + if (false !== strpos($os, 'cygwin')) { + return self::TYPE_CYGWIN; + } + + if (false !== strpos($os, 'darwin')) { + return self::TYPE_DARWIN; + } + + if (false !== strpos($os, 'bsd')) { + return self::TYPE_BSD; + } + + if (0 === strpos($os, 'win')) { + return self::TYPE_WINDOWS; + } + + return self::TYPE_UNIX; + } +} -- cgit v1.2.3-70-g09d2