From 6fdf7435e3b46ba148a3e9101318f9dd196bed4f Mon Sep 17 00:00:00 2001 From: Karel Wintersky Date: Wed, 3 Aug 2022 16:24:19 +0300 Subject: [PATCH] 1.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [R] Release * [*] Upgrade to PHP 7.4 * [*] changed namespace to `ajur-media/fsnews.longreads` * [*] suggests curl/curl * [*] теперь правильно образается подвал * [*] добавлены опции * [*] теперь всегда кидается RuntimeException вместо Exception * [*] fixes --- interfaces/LongreadsInterface.php | 10 ++++++---- sources/Longreads.php | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/interfaces/LongreadsInterface.php b/interfaces/LongreadsInterface.php index 7ff8910..9cebf13 100644 --- a/interfaces/LongreadsInterface.php +++ b/interfaces/LongreadsInterface.php @@ -19,7 +19,7 @@ interface LongreadsInterface * @param array $options * @param LoggerInterface|null $logger */ - public function __construct(PDO $pdo, array $options = [], LoggerInterface $logger = null); + public function __construct(PDO $pdo, array $options = [], $logger = null); /** * Getter @@ -107,14 +107,16 @@ public function deleteStored($id); * @return string */ public function itemToggleVisibility($id, $new_state = 'hide'); - + /** * Возвращает список опубликованных лонгридов на Тильде + * @param null $associative + * @return array + * * @todo: rename * - * @return array */ - public function fetchPagesList(); + public function fetchPagesList(): array; } diff --git a/sources/Longreads.php b/sources/Longreads.php index f4213df..1e1ba93 100644 --- a/sources/Longreads.php +++ b/sources/Longreads.php @@ -8,6 +8,7 @@ use Curl\Curl; use PDOException; +use Psr\Log\NullLogger; use RuntimeException; use PDO; use Psr\Log\LoggerInterface; @@ -93,7 +94,7 @@ class Longreads implements LongreadsInterface */ private $option_download_client; - public function __construct(PDO $pdo, array $options = [], LoggerInterface $logger = null) + public function __construct(PDO $pdo, array $options = [], $logger = null) { $this->api_request_types = [ 'getprojectslist' => '', // Список проектов @@ -107,7 +108,7 @@ public function __construct(PDO $pdo, array $options = [], LoggerInterface $logg ]; $this->pdo = $pdo; - $this->logger = $logger; + $this->logger = is_null($logger) ? new NullLogger() : $logger; $this->api_options['version'] = $options['api.version'] ?? 'v1'; $this->api_options['public_key'] = $options['api.public_key'] ?? false; @@ -157,7 +158,7 @@ public function getStoredAll(string $order_status = 'DESC', string $order_date = $order_status = in_array($order_status, [ 'DESC', 'ASC'] ) ? $order_status : 'DESC'; $order_date = in_array($order_date, [ 'DESC', 'ASC' ] ) ? $order_date : 'DESC'; - $sql = vsprintf("SELECT * FROM %1 ORDER BY status %2, date %3", [ $this->sql_table, $order_status, $order_date ]); + $sql = vsprintf("SELECT * FROM %s ORDER BY status %s, date %s", [ $this->sql_table, $order_status, $order_date ]); $sth = $this->pdo->query($sql); @@ -567,7 +568,7 @@ public function itemToggleVisibility($id, $new_state = 'hide') * * @return array JSON Decoded array */ - public function fetchPagesList() + public function fetchPagesList():array { $request = 'getpageslist'; $pages_list = [