Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

Commit 81c80f9

Browse files
committed
Add support for single files
There may be a time where a user would like to pass just a single file to the formatter instead of an entire directory.
1 parent 8513e35 commit 81c80f9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/PHPFormatter/Finder/FileFinder.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of the php-formatter package
4+
* This file is part of MITRE's ACE project
55
*
6-
* Copyright (c) 2014 Marc Morera
6+
* Copyright (c) 2015 MITRE Corporation
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
1010
*
11-
* Feel free to edit as you please, and have fun.
1211
*
13-
* @author Marc Morera <yuhu@mmoreram.com>
12+
* @author MITRE's ACE Team <ace-team@mitre.org>
1413
*/
1514

1615
namespace Mmoreram\PHPFormatter\Finder;
@@ -32,11 +31,16 @@ class FileFinder
3231
public function findPHPFilesByPath($path)
3332
{
3433
$finder = new Finder();
35-
$finder
36-
->files()
37-
->in($path)
38-
->name('*.php');
39-
34+
35+
if (file_exists($path) && !is_dir($path)) {
36+
$finder->append([0 => $path]);
37+
} else {
38+
$finder
39+
->files()
40+
->in($path)
41+
->name('*.php');
42+
}
43+
4044
return $finder;
4145
}
4246
}

0 commit comments

Comments
 (0)