From d11e74c9c336be45296ce1511264f5ebe9c7939b Mon Sep 17 00:00:00 2001 From: alxndr-w Date: Sun, 17 Sep 2023 10:08:22 +0000 Subject: [PATCH] Apply php-cs-fixer changes --- lib/qanda.php | 61 ++++++++++++++++++++++++++-------------------- lib/qanda_lang.php | 14 ++++++----- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/lib/qanda.php b/lib/qanda.php index aae4cc6..11802b2 100644 --- a/lib/qanda.php +++ b/lib/qanda.php @@ -1,27 +1,29 @@ getCategories()[0]; } + public function getCategories() { return $this->getRelatedCollection('category_ids'); } - public function getQuestion($lang = null) :string + + public function getQuestion($lang = null): string { - if($lang) { - return $this->getTranslation($lang)->getValue("question"); + if ($lang) { + return $this->getTranslation($lang)->getValue('question'); } - return $this->getValue("question"); + return $this->getValue('question'); } + public static function findByIds(array $ids, float $status = 1) { - $ids = implode(",", $ids); - return qanda::query()->whereRaw('status >= '.$status.' AND FIND_IN_SET(id, "'.$ids.'")')->find(); + $ids = implode(',', $ids); + return self::query()->whereRaw('status >= ' . $status . ' AND FIND_IN_SET(id, "' . $ids . '")')->find(); } public static function findByCategoryIds(array $category_ids, float $status = 1) @@ -29,36 +31,39 @@ public static function findByCategoryIds(array $category_ids, float $status = 1) $ids = implode(',', $category_ids); return self::query()->whereRAW('status >= ' . $status . ' AND FIND_IN_SET(category_ids, "' . $ids . '")')->find(); } - public function getAnswer($lang = null) :string + + public function getAnswer($lang = null): string { - if($lang) { - return $this->getTranslation($lang)->getValue("answer"); + if ($lang) { + return $this->getTranslation($lang)->getValue('answer'); } - return $this->getValue("answer"); + return $this->getValue('answer'); } - - public function getAnswerAsPlaintext($lang = null) :string + + public function getAnswerAsPlaintext($lang = null): string { - if($lang) { - return strip_tags($this->getTranslation($lang)->getValue("answer")); + if ($lang) { + return strip_tags($this->getTranslation($lang)->getValue('answer')); } - return strip_tags($this->getValue("answer")); + return strip_tags($this->getValue('answer')); } - public function getTranslation($lang = null) :mixed + public function getTranslation($lang = null): mixed { - if($lang) { + if ($lang) { return qanda_lang::getTranslation($this->getId(), $lang); } - return $this->getRelatedCollection("lang"); + return $this->getRelatedCollection('lang'); } - public function getAuthor() :string + + public function getAuthor(): string { - return $this->getValue("author"); + return $this->getValue('author'); } - public function getUrl($param = "question-header-") + + public function getUrl($param = 'question-header-') { - if (rex_addon::get("yrewrite") && rex_addon::get("yrewrite")->isAvailable()) { + if (rex_addon::get('yrewrite') && rex_addon::get('yrewrite')->isAvailable()) { $host = rex_yrewrite::getFullUrlByArticleId(rex_article::getCurrentId(), rex_clang::getCurrentId()); } else { $host = rtrim(rex::getServer(), '/') . rex_getUrl(rex_article::getCurrentId(), rex_clang::getCurrentId()); @@ -66,16 +71,18 @@ public function getUrl($param = "question-header-") return rtrim($host, '/') . '#' . $param . $this->getId(); } + public static function showJsonLd($question) { - $fragment = new rex_fragment; - $fragment->setVar("question", $question); + $fragment = new rex_fragment(); + $fragment->setVar('question', $question); return $fragment->parse('qanda.json-ld.php'); } + public static function showFAQPage($questions) { - $fragment = new rex_fragment; - $fragment->setVar("questions", $questions); + $fragment = new rex_fragment(); + $fragment->setVar('questions', $questions); return $fragment->parse('FAQPage.json-ld.php'); } } diff --git a/lib/qanda_lang.php b/lib/qanda_lang.php index 8f1263d..b08e27b 100644 --- a/lib/qanda_lang.php +++ b/lib/qanda_lang.php @@ -1,21 +1,23 @@ getValue("answer")); + return strip_tags($this->getValue('answer')); } + public function getQuestion() { - return $this->getValue("question"); + return $this->getValue('question'); } + public function getAnswer() { - return $this->getValue("answer"); + return $this->getValue('answer'); } - public static function getTranslation($question, $lang) :qanda_lang + + public static function getTranslation($question, $lang): self { return self::query()->where('qanda_id', $question)->where('clang_id', $lang)->findOne(); }