generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the user to register which finders to use to the CPUCoreCounter (…
…#20) For BC and convenience, the `CPUCoreCounter` can still be created without any finder which will use the default registered ones. This feature will allow users to blacklist some finders, for example for Psalm which does not want to use the `WindowsWmicFinder`: ```php $finders = array_filter( CpuCoreCounter::getDefaultFinders(), static fn (CpuCoreFinder $finder) => !($finder instanceof WindowsWmicFinder) ); $cores = (new CpuCoreCounter($finders))->getCount(); ``` Another bonus is that it helps out a lot for testing!
- Loading branch information
Showing
7 changed files
with
126 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Fidry CPUCounter Config package. | ||
* | ||
* (c) Théo FIDRY <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Fidry\CpuCounter\Test; | ||
|
||
use Fidry\CpuCounter\CpuCoreFinder; | ||
|
||
final class DummyCpuCoreFinder implements CpuCoreFinder | ||
{ | ||
private ?int $count; | ||
|
||
public function __construct(?int $count) | ||
{ | ||
$this->count = $count; | ||
} | ||
|
||
public function find(): ?int | ||
{ | ||
return $this->count; | ||
} | ||
} |