Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Ignore blade files #155

Merged
merged 1 commit into from Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Infrastructure/Repositories/LocalFilesRepository.php
Expand Up @@ -20,14 +20,15 @@ final class LocalFilesRepository implements FilesRepository
/**
* LocalFilesRepository constructor.
*
* @param \Symfony\Component\Finder\Finder $finder
* @param \Symfony\Component\Finder\Finder $finder
*/
public function __construct(Finder $finder)
{
$this->finder = $finder
->files()
->name(['*.php'])
->exclude(['vendor', 'tests', 'Tests', 'test', 'Test'])
->name(['*.php',])
->exclude(['vendor', 'tests', 'Tests', 'test', 'Test',])
->notName(['*.blade.php',])
olivernybroe marked this conversation as resolved.
Show resolved Hide resolved
// ->ignoreVCSIgnored(true)
->ignoreUnreadableDirs();
}
Expand All @@ -51,7 +52,7 @@ public function getFiles(): iterable
/**
* {@inheritdoc}
*/
public function within(string $directory, array $exclude): FilesRepository
public function within(string $directory, array $exclude = []): FilesRepository
{
$this->finder->in([$directory])->exclude($exclude);

Expand Down
@@ -0,0 +1 @@
A cool login page.
27 changes: 27 additions & 0 deletions tests/Infrastructure/Repositories/LocalFilesRepositoryTest.php
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Tests\Infrastructure\Repositories;

use NunoMaduro\PhpInsights\Infrastructure\Repositories\LocalFilesRepository;
use Symfony\Component\Finder\Finder;
use Tests\TestCase;

/**
* This test class tests if the local file repository works as expected.
*/
final class LocalFilesRepositoryTest extends TestCase
{
public function testCanIgnoreBladeFiles() : void
{
$finder = new Finder();

$repository = new LocalFilesRepository($finder);
$repository->within( __DIR__.'/Fixtures/FolderWithBladeFile');

$files = iterator_to_array($repository->getFiles());

self::assertEmpty($files);
}
}