Skip to content

Commit

Permalink
Move the finders into a dedicated Finder namespace (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Dec 7, 2022
1 parent 49c34df commit 89a5259
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $cores = (new CpuCoreCounter($finders))->getCount();

```php
// Use CPUInfo first & don't use Nproc
use Fidry\CpuCoreCounter\CpuInfoFinder;use Fidry\CpuCoreCounter\HwLogicalFinder;use Fidry\CpuCoreCounter\WindowsWmicFinder;$finders = [
$finders = [
new CpuInfoFinder(),
new WindowsWmicFinder(),
new HwLogicalFinder(),
Expand Down
6 changes: 6 additions & 0 deletions src/CpuCoreCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

namespace Fidry\CpuCoreCounter;

use Fidry\CpuCoreCounter\Finder\CpuCoreFinder;
use Fidry\CpuCoreCounter\Finder\CpuInfoFinder;
use Fidry\CpuCoreCounter\Finder\HwLogicalFinder;
use Fidry\CpuCoreCounter\Finder\NProcFinder;
use Fidry\CpuCoreCounter\Finder\WindowsWmicFinder;

final class CpuCoreCounter
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/CpuCoreFinder.php → src/Finder/CpuCoreFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter;
namespace Fidry\CpuCoreCounter\Finder;

interface CpuCoreFinder
{
Expand Down
2 changes: 1 addition & 1 deletion src/CpuInfoFinder.php → src/Finder/CpuInfoFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter;
namespace Fidry\CpuCoreCounter\Finder;

use function file_get_contents;
use function is_file;
Expand Down
2 changes: 1 addition & 1 deletion src/HwLogicalFinder.php → src/Finder/HwLogicalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter;
namespace Fidry\CpuCoreCounter\Finder;

/**
* Find the number of logical CPU cores for Linux, BSD and OSX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter;
namespace Fidry\CpuCoreCounter\Finder;

/**
* Find the number of physical CPU cores for Linux, BSD and OSX.
Expand Down
2 changes: 1 addition & 1 deletion src/NProcFinder.php → src/Finder/NProcFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter;
namespace Fidry\CpuCoreCounter\Finder;

use Fidry\CpuCoreCounter\Exec\ExecException;
use Fidry\CpuCoreCounter\Exec\ShellExec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter;
namespace Fidry\CpuCoreCounter\Finder;

use function fgets;
use function filter_var;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter;
namespace Fidry\CpuCoreCounter\Finder;

use function defined;

Expand Down
3 changes: 2 additions & 1 deletion tests/CpuCoreCounterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

use Exception;
use Fidry\CpuCoreCounter\CpuCoreCounter;
use Fidry\CpuCoreCounter\CpuCoreFinder;
use Fidry\CpuCoreCounter\Finder\CpuCoreFinder;
use Fidry\CpuCoreCounter\NumberOfCpuCoreNotFound;
use Fidry\CpuCoreCounter\Test\Finder\DummyCpuCoreFinder;
use PHPUnit\Framework\TestCase;
use function get_class;
use function is_int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\CpuInfoFinder;
use Fidry\CpuCoreCounter\Finder\CpuInfoFinder;
use PHPUnit\Framework\TestCase;

/**
* @covers \Fidry\CpuCoreCounter\CpuInfoFinder
* @covers \Fidry\CpuCoreCounter\Finder\CpuInfoFinder
*
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\CpuCoreFinder;
use Fidry\CpuCoreCounter\Finder\CpuCoreFinder;

final class DummyCpuCoreFinder implements CpuCoreFinder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\PopenBasedFinder;
use Fidry\CpuCoreCounter\Finder\PopenBasedFinder;

final class DummyPopenBasedFinder extends PopenBasedFinder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\HwLogicalFinder;
use Fidry\CpuCoreCounter\PopenBasedFinder;
use Fidry\CpuCoreCounter\Finder\HwLogicalFinder;
use Fidry\CpuCoreCounter\Finder\PopenBasedFinder;

/**
* @covers \Fidry\CpuCoreCounter\HwLogicalFinder
* @covers \Fidry\CpuCoreCounter\Finder\HwLogicalFinder
*
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\HwPhysicalFinder;
use Fidry\CpuCoreCounter\PopenBasedFinder;
use Fidry\CpuCoreCounter\Finder\HwPhysicalFinder;
use Fidry\CpuCoreCounter\Finder\PopenBasedFinder;

/**
* @covers \Fidry\CpuCoreCounter\HwPhysicalFinder
* @covers \Fidry\CpuCoreCounter\Finder\HwPhysicalFinder
*
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\NProcFinder;
use Fidry\CpuCoreCounter\Finder\NProcFinder;
use PHPUnit\Framework\TestCase;

/**
* @covers \Fidry\CpuCoreCounter\NProcFinder
* @covers \Fidry\CpuCoreCounter\Finder\NProcFinder
*
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use PHPUnit\Framework\TestCase;

/**
* @covers \Fidry\CpuCoreCounter\PopenBasedFinder
* @covers \Fidry\CpuCoreCounter\Finder\PopenBasedFinder
*
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\PopenBasedFinder;
use Fidry\CpuCoreCounter\Finder\PopenBasedFinder;
use PHPUnit\Framework\TestCase;

abstract class PopenBasedFinderTestCase extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Test;
namespace Fidry\CpuCoreCounter\Test\Finder;

use Fidry\CpuCoreCounter\PopenBasedFinder;
use Fidry\CpuCoreCounter\WindowsWmicFinder;
use Fidry\CpuCoreCounter\Finder\PopenBasedFinder;
use Fidry\CpuCoreCounter\Finder\WindowsWmicFinder;

/**
* @covers \Fidry\CpuCoreCounter\WindowsWmicFinder
* @covers \Fidry\CpuCoreCounter\Finder\WindowsWmicFinder
*
* @internal
*/
Expand Down

0 comments on commit 89a5259

Please sign in to comment.