Главы 30-33: корректура

This commit is contained in:
Igor Simdyanov
2022-07-31 09:57:34 +03:00
parent 0599227ba2
commit fe59bd9e2c
12 changed files with 23 additions and 14 deletions

View File

@ -1,5 +1,6 @@
<?php
interface BackedEnum extends UnitEnum {
interface BackedEnum extends UnitEnum
{
/* Методы */
public static from(int|string $value): static
public static tryFrom(int|string $value): ?static

View File

@ -3,6 +3,6 @@ require_once 'rainbow.php';
$col = Rainbow::Green;
foreach($col->cases() as $object) {
foreach ($col->cases() as $object) {
echo $object->name . '<br />';
}

View File

@ -1,6 +1,6 @@
<?php
require_once 'rainbow.php';
foreach(Rainbow::cases() as $object) {
foreach (Rainbow::cases() as $object) {
echo $object->name . '<br />';
}

View File

@ -1,6 +1,7 @@
<?php
require_once 'rainbow_translate.php';
foreach(Rainbow::cases() as $object) {
echo 'Перевод для ' . $object->russian() . ': ' . $object->english() . '<br />';
foreach (Rainbow::cases() as $object) {
echo 'Перевод для ' . $object->russian() . ': ' .
$object->english() . '<br />';
}

View File

@ -3,6 +3,6 @@ require_once('trait_rainbow.php');
echo 'Количество цветов: '. Rainbow::size() . '<br />' . PHP_EOL;
foreach(Rainbow::cases() as $object) {
foreach (Rainbow::cases() as $object) {
echo $object->russian() . '<br />' . PHP_EOL;
}

View File

@ -3,7 +3,8 @@ require_once 'topic.php';
require_once 'author.php';
require_once 'seo.php';
class Article extends Topic implements Author, Seo {
class Article extends Topic implements Author, Seo
{
public array $authors;
private ?string $seo_title;
private ?string $seo_description;
@ -28,7 +29,7 @@ class Article extends Topic implements Author, Seo {
}
public function title() : ?string
{
if(!empty($this->seo_title)) {
if (!empty($this->seo_title)) {
return $this->seo_title;
} else {
return $this->title;

View File

@ -1,7 +1,10 @@
<?php
interface Seo
{
public function seo(?string $title, ?string $description, ?array $keywords);
public function seo(
?string $title,
?string $description,
?array $keywords);
public function title() : ?string;
public function description() : ?string;
public function keywords() : ?array;

View File

@ -10,7 +10,7 @@ class Topic implements Cover
public string $content,
public ?int $published_at = null)
{
if(empty($published_at)) {
if (empty($published_at)) {
$this->published_at = time();
} else {
$this->published_at = $published_at;

View File

@ -8,7 +8,8 @@ class User
public ?string $last_name = null)
{}
public function fullName() : string {
public function fullName() : string
{
$arr_name = array_filter([$this->first_name, $this->last_name]);
$full_name = implode(' ', $arr_name);
return empty($full_name) ? 'Анонимный пользователь' : $full_name;

View File

@ -3,7 +3,8 @@ require_once 'topic.php';
require_once 'author.php';
require_once 'seo.php';
class Article extends Topic {
class Article extends Topic
{
use Author;
use Seo;
}

View File

@ -16,7 +16,7 @@ trait Seo
}
public function title() : ?string
{
if(!empty($this->seo_title)) {
if (!empty($this->seo_title)) {
return $this->seo_title;
} else {
return $this->title;

View File

@ -8,7 +8,8 @@ class User
public ?string $last_name = null)
{}
public function fullName() : string {
public function fullName() : string
{
$arr_name = array_filter([$this->first_name, $this->last_name]);
$full_name = implode(' ', $arr_name);
return empty($full_name) ? 'Анонимный пользователь' : $full_name;