From c0999196a36aa8577402658579d34231d1ca08ce Mon Sep 17 00:00:00 2001 From: "pieterjan.eilers" Date: Mon, 19 Aug 2024 11:36:43 +0200 Subject: [PATCH] codesniffer --- .../realtimeregister/additionalfields.php | 14 ++- .../realtimeregister/src/Actions/Action.php | 3 +- .../Actions/Contacts/GetContactDetails.php | 12 ++- .../Actions/Contacts/SaveContactDetails.php | 12 ++- .../src/Actions/Domains/CheckAvailability.php | 12 ++- .../Actions/Domains/DomainContactTrait.php | 13 +-- .../src/Actions/Domains/DomainTrait.php | 6 +- .../Actions/Domains/GetDomainInformation.php | 4 +- .../Actions/Domains/RegisterWithBillables.php | 8 +- .../src/Actions/Domains/Sync.php | 6 +- .../src/Actions/Tlds/PricingSync.php | 4 +- .../src/Assets/Js/checkCredentials.js | 100 ++++++++++-------- .../realtimeregister/src/Entities/Domain.php | 6 +- .../src/Entities/RegistrarConfig.php | 6 +- .../src/Enums/WhmcsDomainStatus.php | 9 +- .../src/Hooks/AdminAreaPage.php | 38 ++++--- .../Hooks/PreRegistrarGetContactDetails.php | 6 +- .../realtimeregister/src/LocalApi.php | 24 +++-- .../src/Models/RealtimeRegister/Cache.php | 2 +- .../src/Models/Whmcs/Registrars.php | 14 +-- .../src/Services/Config/Config.php | 2 +- .../src/Services/Config/Repository.php | 18 ++-- .../Services/Config/RepositoryInterface.php | 10 +- .../src/Services/ContactService.php | 40 ++++--- .../src/Services/MetadataService.php | 38 ++++--- .../src/Widget/InformationModuleWidget.php | 2 +- .../realtimeregister/src/helpers.php | 4 +- 27 files changed, 240 insertions(+), 173 deletions(-) diff --git a/modules/registrars/realtimeregister/additionalfields.php b/modules/registrars/realtimeregister/additionalfields.php index 9a72818..705bcf5 100644 --- a/modules/registrars/realtimeregister/additionalfields.php +++ b/modules/registrars/realtimeregister/additionalfields.php @@ -24,7 +24,11 @@ $tlds = []; if (isset($_SESSION['cart']['domains'])) { - $tlds = array_map(function ($domain) { return MetadataService::getTld($domain['domain']); }, $_SESSION['cart']['domains']); + $tlds = array_map( + function ($domain) { + return MetadataService::getTld($domain['domain']); + }, $_SESSION['cart']['domains'] + ); } if (!empty($_POST['domain']) && is_string($_POST['domain'])) { @@ -56,9 +60,11 @@ $fields = $additional['fields'] ?? []; if ($tld !== 'aero') { - $fields = array_filter($fields, function ($field) { - return !in_array($field['Name'], ['AeroId', 'AeroKey']); - }); + $fields = array_filter( + $fields, function ($field) { + return !in_array($field['Name'], ['AeroId', 'AeroKey']); + } + ); } if (empty($fields)) { diff --git a/modules/registrars/realtimeregister/src/Actions/Action.php b/modules/registrars/realtimeregister/src/Actions/Action.php index ce8af3a..b748a47 100644 --- a/modules/registrars/realtimeregister/src/Actions/Action.php +++ b/modules/registrars/realtimeregister/src/Actions/Action.php @@ -51,7 +51,8 @@ protected function metadata(Request $request): TLDMetaData return (new MetadataService($request->domain->tld))->getMetadata(); } - protected function tldInfo(Request $request) : TLDInfo { + protected function tldInfo(Request $request) : TLDInfo + { return (new MetadataService($request->domain->tld))->getAll(); } diff --git a/modules/registrars/realtimeregister/src/Actions/Contacts/GetContactDetails.php b/modules/registrars/realtimeregister/src/Actions/Contacts/GetContactDetails.php index f1c876d..e0110e9 100644 --- a/modules/registrars/realtimeregister/src/Actions/Contacts/GetContactDetails.php +++ b/modules/registrars/realtimeregister/src/Actions/Contacts/GetContactDetails.php @@ -19,21 +19,25 @@ public function __invoke(Request $request): array { $domain = $this->domainInfo($request); - $handles = json_encode([ + $handles = json_encode( + [ ContactModel::ROLE_REGISTRANT => $this->fetchId($domain, DomainContactRoleEnum::ROLE_REGISTRANT), ContactModel::ROLE_ADMIN => $this->fetchId($domain, DomainContactRoleEnum::ROLE_ADMIN), ContactModel::ROLE_TECH => $this->fetchId($domain, DomainContactRoleEnum::ROLE_TECH), ContactModel::ROLE_BILLING => $this->fetchId($domain, DomainContactRoleEnum::ROLE_BILLING) - ]); + ] + ); App::assets()->prependHead(""); - return array_filter([ + return array_filter( + [ ContactModel::ROLE_REGISTRANT => $this->fetchContact($domain, DomainContactRoleEnum::ROLE_REGISTRANT), ContactModel::ROLE_ADMIN => $this->fetchContact($domain, DomainContactRoleEnum::ROLE_ADMIN), ContactModel::ROLE_TECH => $this->fetchContact($domain, DomainContactRoleEnum::ROLE_TECH), ContactModel::ROLE_BILLING => $this->fetchContact($domain, DomainContactRoleEnum::ROLE_BILLING) - ]); + ] + ); } protected function fetchId(DomainDetails $domain, string $role): ?string diff --git a/modules/registrars/realtimeregister/src/Actions/Contacts/SaveContactDetails.php b/modules/registrars/realtimeregister/src/Actions/Contacts/SaveContactDetails.php index 2c2c74c..dd45ae3 100644 --- a/modules/registrars/realtimeregister/src/Actions/Contacts/SaveContactDetails.php +++ b/modules/registrars/realtimeregister/src/Actions/Contacts/SaveContactDetails.php @@ -43,7 +43,9 @@ public function __invoke(Request $request) $key = $role === DomainContactRoleEnum::ROLE_REGISTRANT ? 'registrant' : sprintf('%sContacts', strtolower($role)); - /** @var bool $organizationAllowed */ + /** + * @var bool $organizationAllowed +*/ $organizationAllowed = $metadata->{$key}->organizationAllowed; $currentHandle = $domain->registrant; @@ -63,9 +65,11 @@ public function __invoke(Request $request) ); if ($request->input('wc.' . $whmcsRole) === 'custom') { if (App::contacts()->handleHasMapping($currentHandle)) { - DB::transaction(function () use ($request) { - App::localApi()->createContact(); - }); + DB::transaction( + function () use ($request) { + App::localApi()->createContact(); + } + ); // First create a new contact in whmcs diff --git a/modules/registrars/realtimeregister/src/Actions/Domains/CheckAvailability.php b/modules/registrars/realtimeregister/src/Actions/Domains/CheckAvailability.php index a9a9a4e..b742787 100644 --- a/modules/registrars/realtimeregister/src/Actions/Domains/CheckAvailability.php +++ b/modules/registrars/realtimeregister/src/Actions/Domains/CheckAvailability.php @@ -28,21 +28,25 @@ public function __invoke(Request $request) $searchResult = new SearchResult($request->get('searchTerm'), $tld); - $searchResult->setStatus(match ($result->getStatus()) { + $searchResult->setStatus( + match ($result->getStatus()) { IsProxyDomain::STATUS_AVAILABLE => SearchResult::STATUS_NOT_REGISTERED, IsProxyDomain::STATUS_NOT_AVAILABLE => SearchResult::STATUS_REGISTERED, default => SearchResult::STATUS_UNKNOWN - }); + } + ); $extra = $result->getExtras(); if (isset($extra['type'], $extra['price'], $extra['currency']) && $extra['type'] === 'premium') { $searchResult->setPremiumDomain(true); - $searchResult->setPremiumCostPricing([ + $searchResult->setPremiumCostPricing( + [ 'register' => number_format(($extra['price'] / 100), 2, '.', ''), 'renew' => number_format(($extra['price'] / 100), 2, '.', ''), 'CurrencyCode' => $extra['currency'] - ]); + ] + ); } $results->append($searchResult); diff --git a/modules/registrars/realtimeregister/src/Actions/Domains/DomainContactTrait.php b/modules/registrars/realtimeregister/src/Actions/Domains/DomainContactTrait.php index aecd1fb..fed63ea 100644 --- a/modules/registrars/realtimeregister/src/Actions/Domains/DomainContactTrait.php +++ b/modules/registrars/realtimeregister/src/Actions/Domains/DomainContactTrait.php @@ -6,16 +6,17 @@ use SandwaveIo\RealtimeRegister\Domain\TLDInfo; use SandwaveIo\RealtimeRegister\Domain\TLDMetaData; -trait DomainContactTrait { +trait DomainContactTrait +{ /** * Add properties to contact if necessary - * @param Request $request - * @param string $handle - * @param TLDInfo $tldInfo + * + * @param Request $request + * @param string $handle + * @param TLDInfo $tldInfo * @return void */ - protected static function addProperties(Request $request, string $handle, TLDInfo $tldInfo): void { $customer = App::registrarConfig()->customerHandle(); @@ -38,7 +39,7 @@ protected static function addProperties(Request $request, string $handle, TLDInf } /** - * @param MetadataService $metadata + * @param MetadataService $metadata * @return array */ protected static function getNewProperties(Request $request, TLDMetaData $metadata) : array diff --git a/modules/registrars/realtimeregister/src/Actions/Domains/DomainTrait.php b/modules/registrars/realtimeregister/src/Actions/Domains/DomainTrait.php index 723be05..661037d 100644 --- a/modules/registrars/realtimeregister/src/Actions/Domains/DomainTrait.php +++ b/modules/registrars/realtimeregister/src/Actions/Domains/DomainTrait.php @@ -97,13 +97,15 @@ protected function getDomainNameservers(array $params, string $type = 'register' } } - return array_merge($params, [ + return array_merge( + $params, [ 'ns1' => Configuration::query()->where('setting', 'DefaultNameserver1')->value('value'), 'ns2' => Configuration::query()->where('setting', 'DefaultNameserver2')->value('value'), 'ns3' => Configuration::query()->where('setting', 'DefaultNameserver3')->value('value'), 'ns4' => Configuration::query()->where('setting', 'DefaultNameserver4')->value('value'), 'ns5' => Configuration::query()->where('setting', 'DefaultNameserver5')->value('value') - ]); + ] + ); } /** diff --git a/modules/registrars/realtimeregister/src/Actions/Domains/GetDomainInformation.php b/modules/registrars/realtimeregister/src/Actions/Domains/GetDomainInformation.php index 9431c8b..667a183 100644 --- a/modules/registrars/realtimeregister/src/Actions/Domains/GetDomainInformation.php +++ b/modules/registrars/realtimeregister/src/Actions/Domains/GetDomainInformation.php @@ -46,7 +46,7 @@ public function __invoke(Request $request) } /** - * @param \SandwaveIo\RealtimeRegister\Domain\DomainDetails $domain + * @param \SandwaveIo\RealtimeRegister\Domain\DomainDetails $domain * @return string */ public function getWhmcsDomainStatus(\SandwaveIo\RealtimeRegister\Domain\DomainDetails $domain): string @@ -66,7 +66,7 @@ public function getWhmcsDomainStatus(\SandwaveIo\RealtimeRegister\Domain\DomainD } /** - * @param string $handle + * @param string $handle * @return bool */ public function hasPendingChanges(string $handle): bool diff --git a/modules/registrars/realtimeregister/src/Actions/Domains/RegisterWithBillables.php b/modules/registrars/realtimeregister/src/Actions/Domains/RegisterWithBillables.php index 398b587..d889f58 100644 --- a/modules/registrars/realtimeregister/src/Actions/Domains/RegisterWithBillables.php +++ b/modules/registrars/realtimeregister/src/Actions/Domains/RegisterWithBillables.php @@ -71,7 +71,9 @@ public function __invoke(Request $request): array|string ]; } - /** @var DomainRegistration $registeredDomain */ + /** + * @var DomainRegistration $registeredDomain +*/ $registeredDomain = App::client()->domains->register( domainName: $request->domain->domainName(), customer: App::registrarConfig()->customerHandle(), @@ -97,7 +99,9 @@ private function buildBillables(DomainQuote $quote): array { $billables = []; if (!empty($quote->quote->billables) && $quote->quote->billables->count() > 1) { - /** @var Billable $billable */ + /** + * @var Billable $billable +*/ foreach ($quote->quote->billables as $billable) { $billables[] = [ 'action' => $billable->action, diff --git a/modules/registrars/realtimeregister/src/Actions/Domains/Sync.php b/modules/registrars/realtimeregister/src/Actions/Domains/Sync.php index 87296bb..8379ba5 100644 --- a/modules/registrars/realtimeregister/src/Actions/Domains/Sync.php +++ b/modules/registrars/realtimeregister/src/Actions/Domains/Sync.php @@ -48,8 +48,7 @@ public function __invoke(Request $request) $status = WhmcsDomainStatus::fromDomainDetails($domain); - if ( - !in_array($status, [WhmcsDomainStatus::Active, WhmcsDomainStatus::Expired, WhmcsDomainStatus::Redemption]) + if (!in_array($status, [WhmcsDomainStatus::Active, WhmcsDomainStatus::Expired, WhmcsDomainStatus::Redemption]) ) { throw new Exception(sprintf("Domain status %s", $status->value)); } @@ -72,8 +71,7 @@ protected function syncDueDate(string $date): string protected function parseDomainStatus(array $statuses): string { - if ( - array_intersect([DomainStatusEnum::STATUS_SERVER_HOLD, DomainStatusEnum::STATUS_REGISTRAR_HOLD], $statuses) + if (array_intersect([DomainStatusEnum::STATUS_SERVER_HOLD, DomainStatusEnum::STATUS_REGISTRAR_HOLD], $statuses) ) { return 'Fraud'; } diff --git a/modules/registrars/realtimeregister/src/Actions/Tlds/PricingSync.php b/modules/registrars/realtimeregister/src/Actions/Tlds/PricingSync.php index 10f24cb..87fa649 100644 --- a/modules/registrars/realtimeregister/src/Actions/Tlds/PricingSync.php +++ b/modules/registrars/realtimeregister/src/Actions/Tlds/PricingSync.php @@ -22,7 +22,9 @@ public function __invoke(Request $request) $pricesSLD = []; if (App::registrarConfig()->customerHandle() !== '') { - /** @var Price $priceItem */ + /** + * @var Price $priceItem +*/ foreach (App::client()->customers->priceList(App::registrarConfig()->customerHandle()) as $priceItem) { if (!str_starts_with($priceItem->product, "domain_")) { continue; diff --git a/modules/registrars/realtimeregister/src/Assets/Js/checkCredentials.js b/modules/registrars/realtimeregister/src/Assets/Js/checkCredentials.js index 98746fc..66bb5a9 100644 --- a/modules/registrars/realtimeregister/src/Assets/Js/checkCredentials.js +++ b/modules/registrars/realtimeregister/src/Assets/Js/checkCredentials.js @@ -1,51 +1,57 @@ -$(document).ready(function () { - const moduleName = 'realtimeregister'; - // Container - const config_container = $('#' + moduleName + 'config'); +$(document).ready( + function () { + const moduleName = 'realtimeregister'; + // Container + const config_container = $('#' + moduleName + 'config'); - // Credentials - const handleField = config_container.find('[name="customer_handle"]'); - const apiField = config_container.find('[name="rtr_api_key"]'); - const oteField = config_container.find('[type="checkbox"][name="test_mode"]'); - const ignoreSslField = config_container.find('[type="checkbox"][name="ignore_ssl"]'); + // Credentials + const handleField = config_container.find('[name="customer_handle"]'); + const apiField = config_container.find('[name="rtr_api_key"]'); + const oteField = config_container.find('[type="checkbox"][name="test_mode"]'); + const ignoreSslField = config_container.find('[type="checkbox"][name="ignore_ssl"]'); - config_container.on('click', '.check-connection', function (e) { - e.preventDefault(); + config_container.on( + 'click', '.check-connection', function (e) { + e.preventDefault(); - const btn = $(this); - const text = btn.html(); - const result = config_container.find('.credentials-result'); + const btn = $(this); + const text = btn.html(); + const result = config_container.find('.credentials-result'); - btn.css({'width': btn.outerWidth()}); - btn.html(""); - btn.addClass("disabled"); - btn.attr("disabled", "disabled"); - $.post( - window.location.href, - { - action: 'checkConnection', - module: moduleName, - handle: handleField.val(), - apiKey: apiField.val(), - ote: oteField.is(":checked"), - ignore_ssl: ignoreSslField.is(":checked"), - }, - function (response) { - btn.html(text); - btn.removeClass("disabled"); - if (response.connection === "true") { - result.html('SUCCESSFUL'); - } else { - result.html('FAILED: ' + response.msg + ''); - } - btn.attr("disabled", false); - }, - "json" - ).fail(function (e) { - btn.html(text); - btn.removeClass("disabled"); - btn.attr("disabled", false); - result.html('FAILED: Something went wrong!'); - }); - }); -}); \ No newline at end of file + btn.css({'width': btn.outerWidth()}); + btn.html(""); + btn.addClass("disabled"); + btn.attr("disabled", "disabled"); + $.post( + window.location.href, + { + action: 'checkConnection', + module: moduleName, + handle: handleField.val(), + apiKey: apiField.val(), + ote: oteField.is(":checked"), + ignore_ssl: ignoreSslField.is(":checked"), + }, + function (response) { + btn.html(text); + btn.removeClass("disabled"); + if (response.connection === "true") { + result.html('SUCCESSFUL'); + } else { + result.html('FAILED: ' + response.msg + ''); + } + btn.attr("disabled", false); + }, + "json" + ).fail( + function (e) { + btn.html(text); + btn.removeClass("disabled"); + btn.attr("disabled", false); + result.html('FAILED: Something went wrong!'); + } + ); + } + ); + } +); \ No newline at end of file diff --git a/modules/registrars/realtimeregister/src/Entities/Domain.php b/modules/registrars/realtimeregister/src/Entities/Domain.php index 70d23c9..9f70b31 100644 --- a/modules/registrars/realtimeregister/src/Entities/Domain.php +++ b/modules/registrars/realtimeregister/src/Entities/Domain.php @@ -35,13 +35,15 @@ public static function fromWhmcs(array $params): static return new static( name: $params['sld'], tld: $params['tld'], - nameservers: array_filter([ + nameservers: array_filter( + [ $params['ns1'] ?? null, $params['ns2'] ?? null, $params['ns3'] ?? null, $params['ns4'] ?? null, $params['ns5'] ?? null, - ]), + ] + ), registrant: Contact::fromWhmcs(ContactType::Registrant, $params), admin: Contact::fromWhmcs(ContactType::Admin, $params), tech: Contact::fromWhmcs(ContactType::Tech, $params), diff --git a/modules/registrars/realtimeregister/src/Entities/RegistrarConfig.php b/modules/registrars/realtimeregister/src/Entities/RegistrarConfig.php index 0eda4a4..74457a6 100644 --- a/modules/registrars/realtimeregister/src/Entities/RegistrarConfig.php +++ b/modules/registrars/realtimeregister/src/Entities/RegistrarConfig.php @@ -56,8 +56,10 @@ protected function getRegistrarConfig(string $key, $default = null) protected function loadRegistrarConfig(): void { if ($this->registrarConfig === null) { - /** @noinspection PhpUndefinedConstantInspection */ - require_once ROOTDIR . "/includes/registrarfunctions.php"; + /** + * @noinspection PhpUndefinedConstantInspection +*/ + include_once ROOTDIR . "/includes/registrarfunctions.php"; $this->registrarConfig = array_merge( [ 'SyncStatus' => null, diff --git a/modules/registrars/realtimeregister/src/Enums/WhmcsDomainStatus.php b/modules/registrars/realtimeregister/src/Enums/WhmcsDomainStatus.php index f78972d..d7dd987 100644 --- a/modules/registrars/realtimeregister/src/Enums/WhmcsDomainStatus.php +++ b/modules/registrars/realtimeregister/src/Enums/WhmcsDomainStatus.php @@ -15,11 +15,10 @@ enum WhmcsDomainStatus: string public static function fromDomainDetails(DomainDetails $domain): WhmcsDomainStatus { - if ( - array_intersect( - [DomainStatusEnum::STATUS_SERVER_HOLD, DomainStatusEnum::STATUS_REGISTRAR_HOLD], - $domain->status - ) + if (array_intersect( + [DomainStatusEnum::STATUS_SERVER_HOLD, DomainStatusEnum::STATUS_REGISTRAR_HOLD], + $domain->status + ) ) { return self::Fraud; } diff --git a/modules/registrars/realtimeregister/src/Hooks/AdminAreaPage.php b/modules/registrars/realtimeregister/src/Hooks/AdminAreaPage.php index d5bdb81..aa5dcd7 100644 --- a/modules/registrars/realtimeregister/src/Hooks/AdminAreaPage.php +++ b/modules/registrars/realtimeregister/src/Hooks/AdminAreaPage.php @@ -13,32 +13,36 @@ class AdminAreaPage extends Hook /** * This is a dirty hack to be able to install/update database changes * - * @param DataObject $vars + * @param DataObject $vars * @return void */ public function __invoke(DataObject $vars) { // TODO fix the code in https://gist.github.com/jaceju/cc53d2fbab6e828f69b2a3b7e267d1ed if (!Capsule::schema()->hasTable(ContactMapping::TABLE_NAME)) { - Capsule::schema()->create(ContactMapping::TABLE_NAME, function (Blueprint $table) { - $table->integer('userid'); - $table->integer('contactid'); - $table->char('handle', 40); - $table->boolean('org_allowed'); - $table->unique( - ['userid', 'contactid', 'org_allowed'], - 'mod_realtimeregister_contact_mapping_unique_contact' - ); - $table->unique('handle', 'mod_realtimeregister_contact_mapping_unique_handle'); - }); + Capsule::schema()->create( + ContactMapping::TABLE_NAME, function (Blueprint $table) { + $table->integer('userid'); + $table->integer('contactid'); + $table->char('handle', 40); + $table->boolean('org_allowed'); + $table->unique( + ['userid', 'contactid', 'org_allowed'], + 'mod_realtimeregister_contact_mapping_unique_contact' + ); + $table->unique('handle', 'mod_realtimeregister_contact_mapping_unique_handle'); + } + ); } if (!Capsule::schema()->hasTable(Cache::TABLE_NAME)) { - Capsule::schema()->create(Cache::TABLE_NAME, function ($table) { - $table->string('key')->unique(); - $table->text('value'); - $table->integer('expiration'); - }); + Capsule::schema()->create( + Cache::TABLE_NAME, function ($table) { + $table->string('key')->unique(); + $table->text('value'); + $table->integer('expiration'); + } + ); } } } diff --git a/modules/registrars/realtimeregister/src/Hooks/PreRegistrarGetContactDetails.php b/modules/registrars/realtimeregister/src/Hooks/PreRegistrarGetContactDetails.php index b9a6840..884d57d 100644 --- a/modules/registrars/realtimeregister/src/Hooks/PreRegistrarGetContactDetails.php +++ b/modules/registrars/realtimeregister/src/Hooks/PreRegistrarGetContactDetails.php @@ -9,7 +9,8 @@ class PreRegistrarGetContactDetails extends Hook { public function __invoke(DataObject $vars) { - App::assets()->head(<<head( + << $(document).ready(function() { $('form#frmDomainContactModification > div.row > div[class^=col-]').each(function () { @@ -33,6 +34,7 @@ public function __invoke(DataObject $vars) }); -html); +html + ); } } diff --git a/modules/registrars/realtimeregister/src/LocalApi.php b/modules/registrars/realtimeregister/src/LocalApi.php index c9f0de9..1c32961 100644 --- a/modules/registrars/realtimeregister/src/LocalApi.php +++ b/modules/registrars/realtimeregister/src/LocalApi.php @@ -8,7 +8,7 @@ class LocalApi { /** - * @param array $filters + * @param array $filters * @return Collection */ public function domains(array $filters = []): Collection @@ -21,15 +21,17 @@ public function domains(array $filters = []): Collection public function domain(int $clientId = null, int $domainId = null, string $domain = null): ?DataObject { - return $this->domains([ + return $this->domains( + [ 'clientid' => $clientId, 'domainid' => $domainId, 'domain' => $domain - ])->first(); + ] + )->first(); } /** - * @param array $filters + * @param array $filters * @return Collection */ public function orders(array $filters = []): Collection @@ -45,12 +47,14 @@ public function order( int $requestorId = null, string $status = null ): ?DataObject { - return $this->orders([ + return $this->orders( + [ 'id' => $id, 'clientid' => $clientId, 'requestor_id' => $requestorId, 'status' => $status - ])->first(); + ] + )->first(); } public function client(int $clientId): DataObject @@ -81,8 +85,10 @@ public function contact(int $clientId, int $contactId): ?DataObject public function createContact() { - localAPI('AddContact', [ - 'firstname' => '' - ]); + localAPI( + 'AddContact', [ + 'firstname' => '' + ] + ); } } diff --git a/modules/registrars/realtimeregister/src/Models/RealtimeRegister/Cache.php b/modules/registrars/realtimeregister/src/Models/RealtimeRegister/Cache.php index 1c9050d..58157e5 100644 --- a/modules/registrars/realtimeregister/src/Models/RealtimeRegister/Cache.php +++ b/modules/registrars/realtimeregister/src/Models/RealtimeRegister/Cache.php @@ -70,7 +70,7 @@ public static function get(string $key, $default = null) /** * Store an item in the cache. * - * @param mixed $value + * @param mixed $value * @param \DateTime|int $minutes * @return void */ diff --git a/modules/registrars/realtimeregister/src/Models/Whmcs/Registrars.php b/modules/registrars/realtimeregister/src/Models/Whmcs/Registrars.php index 749d91c..24072e0 100644 --- a/modules/registrars/realtimeregister/src/Models/Whmcs/Registrars.php +++ b/modules/registrars/realtimeregister/src/Models/Whmcs/Registrars.php @@ -26,12 +26,14 @@ public static function getRegistrarConfig($settingParams): array ->whereIn('setting', $settingParams) ->get(); - collect($tblregistrars)->filter(function ($value) { - $value->value = decrypt( - $value->value, - $GLOBALS['cc_encryption_hash'] - ); - }); + collect($tblregistrars)->filter( + function ($value) { + $value->value = decrypt( + $value->value, + $GLOBALS['cc_encryption_hash'] + ); + } + ); $params = []; foreach ($tblregistrars as $param) { diff --git a/modules/registrars/realtimeregister/src/Services/Config/Config.php b/modules/registrars/realtimeregister/src/Services/Config/Config.php index 4c78593..4ab065b 100644 --- a/modules/registrars/realtimeregister/src/Services/Config/Config.php +++ b/modules/registrars/realtimeregister/src/Services/Config/Config.php @@ -23,7 +23,7 @@ public static function get(string $name) return false; } - $config = new Repository(require $configFile); + $config = new Repository(include $configFile); if (!empty($configSettings)) { return $config->get(implode('.', $configSettings)); diff --git a/modules/registrars/realtimeregister/src/Services/Config/Repository.php b/modules/registrars/realtimeregister/src/Services/Config/Repository.php index d651b93..db57910 100644 --- a/modules/registrars/realtimeregister/src/Services/Config/Repository.php +++ b/modules/registrars/realtimeregister/src/Services/Config/Repository.php @@ -31,7 +31,7 @@ public function has(string $key): bool /** * Get the specified configuration value. * - * @param mixed $default + * @param mixed $default * @return mixed */ public function get(string $key, $default = null) @@ -42,8 +42,8 @@ public function get(string $key, $default = null) /** * Set a given configuration value. * - * @param array|string $key - * @param mixed $value + * @param array|string $key + * @param mixed $value * @return void */ public function set($key, $value = null) @@ -58,7 +58,7 @@ public function set($key, $value = null) /** * Prepend a value onto an array configuration value. * - * @param mixed $value + * @param mixed $value * @return void */ public function prepend(string $key, $value) @@ -73,7 +73,7 @@ public function prepend(string $key, $value) /** * Push a value onto an array configuration value. * - * @param mixed $value + * @param mixed $value * @return void */ public function push(string $key, $value) @@ -96,7 +96,7 @@ public function all(): array /** * Determine if the given configuration option exists. * - * @param string $key + * @param string $key */ public function offsetExists($key): bool { @@ -106,7 +106,7 @@ public function offsetExists($key): bool /** * Get a configuration option. * - * @param string $key + * @param string $key * @return mixed */ public function offsetGet($key) @@ -117,7 +117,7 @@ public function offsetGet($key) /** * Set a configuration option. * - * @param mixed $value + * @param mixed $value * @return void */ public function offsetSet($key, $value) @@ -128,7 +128,7 @@ public function offsetSet($key, $value) /** * Unset a configuration option. * - * @param string $key + * @param string $key * @return void */ public function offsetUnset($key): void diff --git a/modules/registrars/realtimeregister/src/Services/Config/RepositoryInterface.php b/modules/registrars/realtimeregister/src/Services/Config/RepositoryInterface.php index 4dc0469..e382d80 100644 --- a/modules/registrars/realtimeregister/src/Services/Config/RepositoryInterface.php +++ b/modules/registrars/realtimeregister/src/Services/Config/RepositoryInterface.php @@ -12,7 +12,7 @@ public function has(string $key): bool; /** * Get the specified configuration value. * - * @param mixed $default + * @param mixed $default * @return mixed */ public function get(string $key, $default = null); @@ -25,8 +25,8 @@ public function all(): array; /** * Set a given configuration value. * - * @param array|string $key - * @param mixed $value + * @param array|string $key + * @param mixed $value * @return void */ public function set($key, $value = null); @@ -34,7 +34,7 @@ public function set($key, $value = null); /** * Prepend a value onto an array configuration value. * - * @param mixed $value + * @param mixed $value * @return void */ public function prepend(string $key, $value); @@ -42,7 +42,7 @@ public function prepend(string $key, $value); /** * Push a value onto an array configuration value. * - * @param mixed $value + * @param mixed $value * @return void */ public function push(string $key, $value); diff --git a/modules/registrars/realtimeregister/src/Services/ContactService.php b/modules/registrars/realtimeregister/src/Services/ContactService.php index 1085719..9e8ccd9 100644 --- a/modules/registrars/realtimeregister/src/Services/ContactService.php +++ b/modules/registrars/realtimeregister/src/Services/ContactService.php @@ -20,10 +20,12 @@ public static function findRemote(DataObject $contact, bool $organizationAllowed $params['organization:null'] = ''; } - $params = array_merge($params, [ + $params = array_merge( + $params, [ 'order' => '-createdDate', 'export' => true - ]); + ] + ); return App::client()->contacts->list( customer: App::registrarConfig()->customerHandle(), @@ -33,7 +35,9 @@ public static function findRemote(DataObject $contact, bool $organizationAllowed public static function getContactMapping(int $userId, int $contactId, bool $organizationAllowed) : ?ContactMapping { - /** @noinspection PhpIncompatibleReturnTypeInspection */ + /** + * @noinspection PhpIncompatibleReturnTypeInspection +*/ return ContactMapping::query()->where('userid', $userId) ->where('contactid', $contactId) ->where('org_allowed', $organizationAllowed) @@ -73,8 +77,8 @@ public static function convertToRtrContact(DataObject $whmcsContact, bool $organ } /** - * @param string|int $userId - * @param string|int $contactId + * @param string|int $userId + * @param string|int $contactId * @return Collection */ public function fetchMappingByContactId(string|int $userId, string|int $contactId): Collection @@ -84,7 +88,9 @@ public function fetchMappingByContactId(string|int $userId, string|int $contactI public function fetchMappingByHandle(string $handle): ?ContactMapping { - /** @noinspection PhpIncompatibleReturnTypeInspection */ + /** + * @noinspection PhpIncompatibleReturnTypeInspection +*/ return ContactMapping::query()->where('handle', $handle)->first(); } @@ -95,24 +101,26 @@ public function handleHasMapping(string $handle): bool public static function addContactMapping(int $clientId, int $contactId, string $handle, bool $orgAllowed): void { - ContactMapping::query()->insert([ + ContactMapping::query()->insert( + [ "userid" => $clientId, "contactid" => $contactId, "handle" => $handle, "org_allowed" => $orgAllowed - ]); + ] + ); } public static function getMatchingRtrContact() { //TODO if necessary -// App::client()->contacts->list( -// App::registrarConfig()->get('customer_handle'), -// parameters: [ -// 'order' => '-createdDate', -// 'export' => true, -// 'fields' => 'handle' -// ] -// )->first(); + // App::client()->contacts->list( + // App::registrarConfig()->get('customer_handle'), + // parameters: [ + // 'order' => '-createdDate', + // 'export' => true, + // 'fields' => 'handle' + // ] + // )->first(); } } diff --git a/modules/registrars/realtimeregister/src/Services/MetadataService.php b/modules/registrars/realtimeregister/src/Services/MetadataService.php index 2798edc..5fcdbae 100644 --- a/modules/registrars/realtimeregister/src/Services/MetadataService.php +++ b/modules/registrars/realtimeregister/src/Services/MetadataService.php @@ -14,7 +14,9 @@ class MetadataService public const DAY_MINUTES = 14400; private string $tld; private string $provider; - /** @var TLDInfo */ + /** + * @var TLDInfo + */ private $info; public function __construct(string $tld) @@ -22,13 +24,17 @@ public function __construct(string $tld) $tld = self::getTld($tld); $this->tld = $tld; - $this->info = TLDInfo::fromArray(Cache::remember('tld.' . $this->tld, MetadataService::DAY_MINUTES, function () { - $metadata = App::client()->tlds->info($this->tld); - foreach ($metadata->applicableFor as $app_tld) { - Cache::put('tld.' . $app_tld, $metadata, MetadataService::DAY_MINUTES); - } - return $metadata->toArray(); - })); + $this->info = TLDInfo::fromArray( + Cache::remember( + 'tld.' . $this->tld, MetadataService::DAY_MINUTES, function () { + $metadata = App::client()->tlds->info($this->tld); + foreach ($metadata->applicableFor as $app_tld) { + Cache::put('tld.' . $app_tld, $metadata, MetadataService::DAY_MINUTES); + } + return $metadata->toArray(); + } + ) + ); $this->provider = $this->info->provider; } @@ -44,7 +50,7 @@ public function getAll(): TLDInfo } /** - * @param string $param + * @param string $param * @return string|int|array|bool */ public function get(string $param) @@ -68,7 +74,7 @@ public function getApplicableFor() } /** - * @param string $domain the domain name + * @param string $domain the domain name * @return string */ public static function getTld($domain) @@ -255,16 +261,20 @@ function ($names, $tld) use ($rtrAdditionalFields) { } } - public static function getAllTlds() : array { - $providers = Cache::remember("rtrProviders", self::DAY_MINUTES, fn () => + public static function getAllTlds() : array + { + $providers = Cache::remember( + "rtrProviders", self::DAY_MINUTES, fn () => App::client()->providers->list(parameters: ["fields" => "tlds", "export" => "true"])->toArray() ); - return array_map(fn($tld) => $tld['name'], + return array_map( + fn($tld) => $tld['name'], array_merge(...array_map(fn($provider) => $provider['tlds'], $providers)) ); } - public static function isRtr($tld) { + public static function isRtr($tld) + { return DomainPricing::query() ->where("extension", "." . $tld) ->whereIn("autoreg", ["realtimeregister", ""]) diff --git a/modules/registrars/realtimeregister/src/Widget/InformationModuleWidget.php b/modules/registrars/realtimeregister/src/Widget/InformationModuleWidget.php index 2701176..83fdf4a 100644 --- a/modules/registrars/realtimeregister/src/Widget/InformationModuleWidget.php +++ b/modules/registrars/realtimeregister/src/Widget/InformationModuleWidget.php @@ -16,7 +16,7 @@ class InformationModuleWidget extends \WHMCS\Module\AbstractWidget public function getData() { -// $credits = App::client()->customers->credits(App::registrarConfig()->customerHandle()); + // $credits = App::client()->customers->credits(App::registrarConfig()->customerHandle()); return []; } diff --git a/modules/registrars/realtimeregister/src/helpers.php b/modules/registrars/realtimeregister/src/helpers.php index 362f31e..2cc8f0f 100644 --- a/modules/registrars/realtimeregister/src/helpers.php +++ b/modules/registrars/realtimeregister/src/helpers.php @@ -3,8 +3,8 @@ namespace RealtimeRegister { if (!function_exists('view')) { /** - * @param $template - * @param array $args + * @param $template + * @param array $args * @return string * @throws Exception * @throws SmartyException