| Total Complexity | 5 | 
| Total Lines | 41 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 10 | final class FoundMoreNews implements PolicyConditionInterface | ||
| 11 | { | ||
| 12 | public const NEWS = 'NEWS'; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * @var array<string,string> | ||
| 16 | * For example ['TickerSymbol' => 'datetime'] | ||
| 17 | */ | ||
| 18 | private static array $cacheOldestDateTimeBySymbol = []; | ||
| 19 | |||
| 20 | 1 | public function __construct() | |
| 21 |     { | ||
| 22 | // TODO: Add as optional arg: the datetime from where to start looking for news. | ||
| 23 | 1 | } | |
| 24 | |||
| 25 | 1 | public function __invoke(Company $company): bool | |
| 26 |     { | ||
| 27 | 1 | $current = $this->findLatestDateTimeFromNews($company); | |
| 28 | 1 | $previous = self::$cacheOldestDateTimeBySymbol[$company->symbol()->toString()] ?? ''; | |
| 29 | |||
| 30 | 1 | self::$cacheOldestDateTimeBySymbol[$company->symbol()->toString()] = $current; | |
| 31 | |||
| 32 | 1 | return $current > $previous; | |
| 33 | } | ||
| 34 | |||
| 35 | 1 | private function findLatestDateTimeFromNews(Company $company): string | |
| 51 | } | ||
| 52 | } | ||
| 53 |