Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
  • Loading branch information
saundefined and TimWolla authored Oct 23, 2024
1 parent 93a95bf commit aa9e3e6
Showing 1 changed file with 55 additions and 19 deletions.
74 changes: 55 additions & 19 deletions releases/8.4/release.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,47 @@ common_header(message('common_header', $lang));
<div class="php8-code phpcode">
<?php highlight_php_trimmed(
<<<'PHP'
class User
class Locale
{
public function __construct(
private string $first,
private string $last,
) {}
private string $languageCode;
private string $countryCode;
public function __construct(string $languageCode, string $countryCode) {
$this->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

); ?>
Expand All @@ -69,22 +95,32 @@ PHP
<div class="php8-code phpcode">
<?php highlight_php_trimmed(
<<<'PHP'
class User
class Locale
{
public function __construct(
private string $first,
private string $last,
) {}
public string $fullName {
get {
return $this->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
); ?>
</div>
Expand Down

0 comments on commit aa9e3e6

Please sign in to comment.