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

Move the finders into a dedicated Finder namespace #48

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Move the finders into a dedicated Finder namespace
  • Loading branch information
theofidry committed Dec 7, 2022
commit 367bbfa4002fe4339dc03c7a495f2a4ab873d866
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 = [
use Fidry\CpuCoreCounter\Finder\CpuInfoFinder;use Fidry\CpuCoreCounter\Finder\HwLogicalFinder;use Fidry\CpuCoreCounter\Finder\WindowsWmicFinder;$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