| src/HolidaySkipper.php | ●●●●● patch | view | raw | blame | history | |
| src/UcrmHelper.php | ●●●●● patch | view | raw | blame | history |
src/HolidaySkipper.php
@@ -8,15 +8,15 @@ use Umulmrum\Holiday\Model\HolidayList; class HolidaySkipper { protected $helper; protected $skipDays = null; protected $holidays = null; protected UcrmHelper $helper; protected ?array $skipDays = null; protected ?HolidayList $holidays = null; function __construct(UcrmHelper $ucrmHelper) { $this->helper = $ucrmHelper; } protected function configure(array $years) { protected function configure(array $years): void { $config = $this->helper->getConfig(); if ($this->skipDays === NULL) { @@ -39,7 +39,7 @@ } } function processInvoice(string $invoiceId) { function processInvoice(string $invoiceId): bool { $crm = $this->helper->getApi(); $invoiceData = $crm->get('/invoices/' . $invoiceId); if ($invoiceData['status'] != 0) { @@ -71,5 +71,7 @@ } else { echo 'Invoice ' . $invoiceId . ': nothing to do' . "\n"; } return $changed > 0; } } src/UcrmHelper.php
@@ -3,9 +3,9 @@ namespace SIPL\UCRM\Holidays; class UcrmHelper { protected $rootDirectory; protected $api = NULL; protected $config = NULL; protected string $rootDirectory; protected ?\Ubnt\UcrmPluginSdk\Service\UcrmApi $api = NULL; protected ?array $config = NULL; protected $event = NULL; function __construct(?string $rootDirectory = NULL) { @@ -15,18 +15,18 @@ $this->rootDirectory = $rootDirectory; } function getRootDirectory() { function getRootDirectory(): string { return $this->rootDirectory; } function getApi() { function getApi(): \Ubnt\UcrmPluginSdk\Service\UcrmApi { if ($this->api === NULL) { $this->api = \Ubnt\UcrmPluginSdk\Service\UcrmApi::create($this->rootDirectory); } return $this->api; } function getConfig() { function getConfig(): array { if ($this->config === NULL) { $configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create($this->rootDirectory); $this->config = $configManager->loadConfig(); @@ -34,7 +34,7 @@ return $this->config; } function getCurrentEvent() { function getCurrentEvent(): array { if ($this->event === NULL) { try { if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {