From aa9e3e65aa329980f3e7fcd817d1c3e810a01ee9 Mon Sep 17 00:00:00 2001 From: Sergey Panteleev Date: Wed, 23 Oct 2024 18:11:40 +0300 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tim Düsterhus --- releases/8.4/release.inc | 74 +++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/releases/8.4/release.inc b/releases/8.4/release.inc index f17c8ec2b1..b32aca6a56 100644 --- a/releases/8.4/release.inc +++ b/releases/8.4/release.inc @@ -43,21 +43,47 @@ common_header(message('common_header', $lang));
setLanguageCode($languageCode); + $this->setCountryCode($countryCode); + } + + public function getLanguageCode(): string { + return $this->languageCode; + } + + public function setLanguageCode(string $languageCode): void { + $this->languageCode = $languageCode; + } + + public function getCountryCode(): string { + return $this->countryCode; + } + + public function setCountryCode(string $countryCode): void { + $this->countryCode = strtoupper($countryCode); + } + + public function setCombinedCode(string $combinedCode): void { + [$languageCode, $countryCode] = explode('_', $combinedCode, 2); - public function setFullName(string $value): string { - [$this->first, $this->last] = explode(' ', $value, 2); + $this->setLanguageCode($languageCode); + $this->setCountryCode($countryCode); } - public function getFullName(): string { - return $this->first . ' ' . $this->last; + public function getCombinedCode(): string { + return \sprintf("%s_%s", $this->languageCode, $this->countryCode); } } + +$brazilianPortuguese = new Locale('pt', 'br'); +var_dump($brazilianPortuguese->getCountryCode()); // BR +var_dump($brazilianPortuguese->getCombinedCode()); // pt_BR PHP ); ?> @@ -69,22 +95,32 @@ PHP
first . " " . $this->last; + public string $languageCode; + + public string $countryCode { + set (string $countryCode) { + $this->countryCode = strtoupper($countryCode); } + } + + public string $combinedCode { + get => \sprintf("%s_%s", $this->languageCode, $this->countryCode); set (string $value) { - [$this->first, $this->last] = explode(' ', $value, 2); + [$this->countryCode, $this->languageCode] = explode(' ', $value, 2); } } + + public function __construct(string $languageCode, string $countryCode) { + $this->languageCode = $languageCode; + $this->countryCode = $countryCode; + } } + +$brazilianPortuguese = new Locale('pt', 'br'); +var_dump($brazilianPortuguese->getCountryCode()); // BR +var_dump($brazilianPortuguese->getCombinedCode()); // pt_BR PHP ); ?>