-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add final or abstract keyword when missing
- Loading branch information
Showing
53 changed files
with
332 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Churn\Assessor; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
interface Assessor | ||
{ | ||
/** | ||
* Assess a PHP file. | ||
* | ||
* @param string $contents The contents of a PHP file. | ||
*/ | ||
public function assess(string $contents): int; | ||
} |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
/** | ||
* @internal | ||
*/ | ||
class Config | ||
abstract class Config | ||
{ | ||
/** | ||
* @var array<string> | ||
|
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Churn\Configuration; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class ReadOnlyConfig extends Config | ||
{ | ||
} |
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,77 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Churn\Event; | ||
|
||
use Churn\Event\Channel\AfterAnalysisChannel; | ||
use Churn\Event\Channel\AfterFileAnalysisChannel; | ||
use Churn\Event\Channel\BeforeAnalysisChannel; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class BrokerImpl implements Broker | ||
{ | ||
/** | ||
* @var array<string, array<callable>> | ||
* @psalm-var array<class-string, array<callable>> | ||
*/ | ||
private $subscribers = []; | ||
|
||
/** | ||
* @var array<\Churn\Event\Channel> | ||
*/ | ||
private $channels; | ||
|
||
/** | ||
* Class constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->channels = [ | ||
new AfterAnalysisChannel(), | ||
new AfterFileAnalysisChannel(), | ||
new BeforeAnalysisChannel(), | ||
]; | ||
} | ||
|
||
/** | ||
* @param object $subscriber A subscriber object. | ||
*/ | ||
public function subscribe($subscriber): void | ||
{ | ||
foreach ($this->channels as $channel) { | ||
if (!$channel->accepts($subscriber)) { | ||
continue; | ||
} | ||
|
||
$this->subscribers[$channel->getEventClassname()][] = $channel->buildEventHandler($subscriber); | ||
} | ||
} | ||
|
||
/** | ||
* @param Event $event The triggered event. | ||
*/ | ||
public function notify(Event $event): void | ||
{ | ||
foreach ($this->subscribers as $eventClass => $subscribers) { | ||
if (!$event instanceof $eventClass) { | ||
continue; | ||
} | ||
|
||
$this->notifyAll($event, $subscribers); | ||
} | ||
} | ||
|
||
/** | ||
* @param Event $event The triggered event. | ||
* @param array<callable> $subscribers The subscribers to notify. | ||
*/ | ||
private function notifyAll(Event $event, array $subscribers): void | ||
{ | ||
foreach ($subscribers as $subscriber) { | ||
$subscriber($event); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.