| 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 | /** |
||
| 13 | * @var array<string,string> |
||
| 14 | * For example ['TickerSymbol' => 'datetime'] |
||
| 15 | */ |
||
| 16 | private static array $cacheOldestDateTimeBySymbol = []; |
||
| 17 | |||
| 18 | private string $companyKey; |
||
| 19 | |||
| 20 | 1 | public function __construct(string $companyKey) |
|
| 21 | { |
||
| 22 | 1 | $this->companyKey = $companyKey; |
|
| 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 |