pax_global_header00006660000000000000000000000064136100150150014502gustar00rootroot0000000000000052 comment=167c45d131f7fc3d159f56f191a0a22228765e16 finder-facade-1.2.3/000077500000000000000000000000001361001501500141555ustar00rootroot00000000000000finder-facade-1.2.3/.gitattributes000066400000000000000000000000171361001501500170460ustar00rootroot00000000000000*.php diff=php finder-facade-1.2.3/.gitignore000066400000000000000000000000551361001501500161450ustar00rootroot00000000000000/.idea /composer.lock /composer.phar /vendor finder-facade-1.2.3/LICENSE000066400000000000000000000030131361001501500151570ustar00rootroot00000000000000FinderFacade Copyright (c) 2012-2020, Sebastian Bergmann . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Sebastian Bergmann nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. finder-facade-1.2.3/README.md000066400000000000000000000010101361001501500154240ustar00rootroot00000000000000# FinderFacade **FinderFacade** is a convenience wrapper for Symfony's [Finder](http://symfony.com/doc/2.2/components/finder.html) component. ## Installation To add this package as a local, per-project dependency to your project, simply add a dependency on `sebastian/finder-facade` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on FinderFacade 1.1: { "require": { "sebastian/finder-facade": "~1.1" } } finder-facade-1.2.3/build.xml000066400000000000000000000014561361001501500160040ustar00rootroot00000000000000 finder-facade-1.2.3/composer.json000066400000000000000000000017151361001501500167030ustar00rootroot00000000000000{ "name": "sebastian/finder-facade", "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", "homepage": "https://github.com/sebastianbergmann/finder-facade", "license": "BSD-3-Clause", "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de", "role": "lead" } ], "support": { "issues": "https://github.com/sebastianbergmann/finder-facade/issues" }, "prefer-stable": true, "require": { "php": "^7.1", "theseer/fdomdocument": "^1.6", "symfony/finder": "^2.3|^3.0|^4.0|^5.0" }, "config": { "platform": { "php": "7.1.3" }, "optimize-autoloader": true, "sort-packages": true }, "autoload": { "classmap": [ "src/" ] }, "extra": { "branch-alias": { "dev-master": "1.2" } } } finder-facade-1.2.3/src/000077500000000000000000000000001361001501500147445ustar00rootroot00000000000000finder-facade-1.2.3/src/Configuration.php000066400000000000000000000057021361001501500202700ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\FinderFacade; use TheSeer\fDOM\fDOMDocument; /** * * * * /path/to/directory * /path/to/file * * /path/to/directory * *.php * * * * @since Class available since Release 1.0.0 */ class Configuration { /** * @var string */ protected $basePath; /** * @var fDOMDocument */ protected $xml; /** * @param string $file */ public function __construct($file) { $this->basePath = dirname($file); $this->xml = new fDOMDocument; $this->xml->load($file); } /** * @param string $xpath * * @return array */ public function parse($xpath = '') { $result = array( 'items' => array(), 'excludes' => array(), 'names' => array(), 'notNames' => array(), 'regularExpressionExcludes' => array() ); foreach ($this->xml->getDOMXPath()->query($xpath . 'include/directory') as $item) { $result['items'][] = $this->toAbsolutePath($item->nodeValue); } foreach ($this->xml->getDOMXPath()->query($xpath . 'include/file') as $item) { $result['items'][] = $this->toAbsolutePath($item->nodeValue); } foreach ($this->xml->getDOMXPath()->query($xpath . 'exclude') as $exclude) { $result['excludes'][] = $exclude->nodeValue; } foreach ($this->xml->getDOMXPath()->query($xpath . 'name') as $name) { $result['names'][] = $name->nodeValue; } foreach ($this->xml->getDOMXPath()->query($xpath . 'notName') as $notName) { $result['notNames'][] = $notName->nodeValue; } foreach ($this->xml->getDOMXPath()->query($xpath . 'regularExpressionExcludes') as $regularExpressionExclude) { $result['regularExpressionExcludes'][] = $regularExpressionExclude->nodeValue; } return $result; } /** * @param string $path * * @return string */ protected function toAbsolutePath($path) { // Check whether the path is already absolute. if ($path[0] === '/' || $path[0] === '\\' || (strlen($path) > 3 && ctype_alpha($path[0]) && $path[1] === ':' && ($path[2] === '\\' || $path[2] === '/'))) { return $path; } // Check whether a stream is used. if (strpos($path, '://') !== false) { return $path; } return $this->basePath . DIRECTORY_SEPARATOR . $path; } } finder-facade-1.2.3/src/FinderFacade.php000066400000000000000000000060311361001501500177500ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\FinderFacade; use Symfony\Component\Finder\Finder; /** * Convenience wrapper for Symfony's Finder component. * * @since Class available since Release 1.0.0 */ class FinderFacade { /** * @var array */ protected $items = array(); /** * @var array */ protected $excludes = array(); /** * @var array */ protected $names = array(); /** * @var array */ protected $notNames = array(); /** * @var array */ protected $regularExpressionsExcludes = array(); /** * @param array $items * @param array $excludes * @param array $names * @param array $notNames * @param array $regularExpressionsExcludes */ public function __construct(array $items = array(), array $excludes = array(), array $names = array(), array $notNames = array(), $regularExpressionsExcludes = array()) { $this->items = $items; $this->excludes = $excludes; $this->names = $names; $this->notNames = $notNames; $this->regularExpressionsExcludes = $regularExpressionsExcludes; } /** * @return array */ public function findFiles() { $files = array(); $finder = new Finder; $iterate = false; $finder->ignoreUnreadableDirs(); foreach ($this->items as $item) { if (!is_file($item)) { $finder->in($item); $iterate = true; } else { $files[] = realpath($item); } } foreach ($this->excludes as $exclude) { $finder->exclude($exclude); } foreach ($this->names as $name) { $finder->name($name); } foreach ($this->notNames as $notName) { $finder->notName($notName); } foreach ($this->regularExpressionsExcludes as $regularExpressionExclude) { $finder->notPath($regularExpressionExclude); } if ($iterate) { foreach ($finder as $file) { $files[] = $file->getRealpath(); } } return $files; } /** * @param string $file */ public function loadConfiguration($file) { $configuration = new Configuration($file); $configuration = $configuration->parse(); $this->items = $configuration['items']; $this->excludes = $configuration['excludes']; $this->names = $configuration['names']; $this->notNames = $configuration['notNames']; $this->regularExpressionsExcludes = $configuration['regularExpressionExcludes']; } } finder-facade-1.2.3/tests/000077500000000000000000000000001361001501500153175ustar00rootroot00000000000000finder-facade-1.2.3/tests/ConfigurationTest.php000066400000000000000000000025621361001501500215040ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\FinderFacade; class ConfigurationTest extends \PHPUnit_Framework_TestCase { protected $fixtureDir; protected function setUp() { $this->fixtureDir = __DIR__ . DIRECTORY_SEPARATOR . 'fixture' . DIRECTORY_SEPARATOR; } /** * @covers SebastianBergmann\FinderFacade\Configuration::__construct * @covers SebastianBergmann\FinderFacade\Configuration::parse * @covers SebastianBergmann\FinderFacade\Configuration::toAbsolutePath */ public function testXmlFileCanBeParsed() { $configuration = new Configuration($this->fixtureDir . 'test.xml'); $this->assertEquals( array( 'items' => array( $this->fixtureDir . 'foo', $this->fixtureDir . 'bar.phtml' ), 'excludes' => array('bar'), 'names' => array('*.php'), 'notNames' => array('*.fail.php'), 'regularExpressionExcludes' => array() ), $configuration->parse() ); } } finder-facade-1.2.3/tests/FinderFacadeTest.php000066400000000000000000000032471361001501500211710ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\FinderFacade; class FinderFacadeTest extends \PHPUnit_Framework_TestCase { protected $fixtureDir; protected function setUp() { $this->fixtureDir = __DIR__ . DIRECTORY_SEPARATOR . 'fixture' . DIRECTORY_SEPARATOR; } /** * @covers SebastianBergmann\FinderFacade\FinderFacade::__construct * @covers SebastianBergmann\FinderFacade\FinderFacade::findFiles */ public function testFilesCanBeFoundBasedOnConstructorArguments() { $facade = new FinderFacade( array($this->fixtureDir, $this->fixtureDir . 'bar.phtml'), array('bar'), array('*.php'), array('*.fail.php') ); $this->assertEquals( array( $this->fixtureDir . 'bar.phtml', $this->fixtureDir . 'foo' . DIRECTORY_SEPARATOR . 'bar.php' ), $facade->findFiles() ); } /** * @covers SebastianBergmann\FinderFacade\FinderFacade::loadConfiguration */ public function testFilesCanBeFoundBasedOnXmlConfiguration() { $facade = new FinderFacade; $facade->loadConfiguration($this->fixtureDir . 'test.xml'); $this->assertEquals( array( $this->fixtureDir . 'bar.phtml', $this->fixtureDir . 'foo' . DIRECTORY_SEPARATOR . 'bar.php' ), $facade->findFiles() ); } } finder-facade-1.2.3/tests/fixture/000077500000000000000000000000001361001501500170055ustar00rootroot00000000000000finder-facade-1.2.3/tests/fixture/bar.phtml000066400000000000000000000000001361001501500206050ustar00rootroot00000000000000finder-facade-1.2.3/tests/fixture/foo/000077500000000000000000000000001361001501500175705ustar00rootroot00000000000000finder-facade-1.2.3/tests/fixture/foo/bar.php000066400000000000000000000000001361001501500210330ustar00rootroot00000000000000finder-facade-1.2.3/tests/fixture/foo/bar/000077500000000000000000000000001361001501500203345ustar00rootroot00000000000000finder-facade-1.2.3/tests/fixture/foo/bar/baz.php000066400000000000000000000000001361001501500216070ustar00rootroot00000000000000finder-facade-1.2.3/tests/fixture/foo/foo.fail.php000066400000000000000000000000001361001501500217640ustar00rootroot00000000000000finder-facade-1.2.3/tests/fixture/test.xml000066400000000000000000000002551361001501500205100ustar00rootroot00000000000000 foo bar.phtml bar *.php *.fail.php