Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
* [R] Release
* [*] Upgrade to PHP 7.4
* [*] changed namespace to `ajur-media/fsnews.longreads`
* [*] suggests curl/curl
* [*] теперь правильно образается подвал
* [*] добавлены опции
* [*] теперь всегда кидается RuntimeException вместо Exception
* [*] fixes
  • Loading branch information
KarelWintersky committed Aug 3, 2022
1 parent c56dc7c commit 6fdf743
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions interfaces/LongreadsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

}

Expand Down
9 changes: 5 additions & 4 deletions sources/Longreads.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Curl\Curl;
use PDOException;
use Psr\Log\NullLogger;
use RuntimeException;
use PDO;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -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' => '', // Список проектов
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 6fdf743

Please sign in to comment.