Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
phattarachai committed Feb 10, 2022
1 parent e879c43 commit 9506a92
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"homepage": "https://phattarachai.dev",
"require": {
"php": "^7.3|^8.0",
"php": "^7.4|^8.0",
"guzzlehttp/guzzle": "^7.2",
"illuminate/support": "^7.0|^8.0",
"ext-json": "*"
Expand Down
25 changes: 13 additions & 12 deletions src/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;

class Line
{
protected $client;
protected $token;
protected $thumbnailUrl = null;
protected $imageUrl = null;
protected $imagePath = null;
protected $notificationDisabled = false;
protected $stickerPackageId = null;
protected $stickerId = null;
protected Client $client;
protected string $token;
protected ?string $imageUrl = null;
protected ?string $imagePath = null;
protected ?string $stickerId = null;
protected ?string $thumbnailUrl = null;
protected ?string $stickerPackageId = null;
protected bool $notificationDisabled = false;

public const URL = 'https://notify-api.line.me/api/notify';

Expand All @@ -31,7 +32,7 @@ public function __construct(string $token = '')
*
* @param string $token the token of Line notify
*/
public function setToken(string $token)
public function setToken(string $token): Line
{
$this->token = $token;
return $this;
Expand All @@ -55,7 +56,7 @@ public function imagePath(string $path): Line
return $this;
}

public function sticker(int $sticker_package_id, int $sticker_id)
public function sticker(int $sticker_package_id, int $sticker_id): Line
{
$this->stickerPackageId = $sticker_package_id;
$this->stickerId = $sticker_id;
Expand Down Expand Up @@ -90,11 +91,11 @@ public function send(string $message): bool
}

/**
* @param \Psr\Http\Message\ResponseInterface $response
* @param ResponseInterface $response
* @return bool
* @throws \JsonException
*/
protected function isSuccess(\Psr\Http\Message\ResponseInterface $response): bool
protected function isSuccess(ResponseInterface $response): bool
{
$json = json_decode((string)$response->getBody(), true, 512, JSON_THROW_ON_ERROR);

Expand Down
18 changes: 8 additions & 10 deletions tests/LineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

use Dotenv\Dotenv;
use Phattarachai\LineNotify\Line;
use PHPUnit\Framework\TestCase;


class LineTest extends \PHPUnit\Framework\TestCase
class LineTest extends TestCase
{

/**
* @var Line
*/
protected Line $line;

protected function setUp(): void
Expand All @@ -22,13 +20,13 @@ protected function setUp(): void
$this->line = new Line($_ENV['LINE_ACCESS_TOKEN']);
}

public function test_send_message()
public function test_send_message(): void
{
$this->line->send('ทดสอบ');
self::assertTrue(true);
}

public function test_send_image_from_url_with_thumbnail_url()
public function test_send_image_from_url_with_thumbnail_url(): void
{
$this->line->thumbnailUrl('https://phattarachai.dev/images/logo-purple.png')
->imageUrl('https://me.phattarachai.dev/wp-content/uploads/2021/02/laravel8-1.jpg')
Expand All @@ -37,31 +35,31 @@ public function test_send_image_from_url_with_thumbnail_url()
self::assertTrue(true);
}

public function test_send_image_from_url_without_thumbnail_url()
public function test_send_image_from_url_without_thumbnail_url(): void
{
$this->line->imageUrl('https://me.phattarachai.dev/wp-content/uploads/2021/02/laravel8-1.jpg')
->send('ข้อความ และ Image');

self::assertTrue(true);
}

public function test_upload_image()
public function test_upload_image(): void
{
$this->line->imagePath(__DIR__ . '/../art/line-notify-banner.jpg')
->send('ข้อความ และ Upload Image');

self::assertTrue(true);
}

public function test_send_sticker()
public function test_send_sticker(): void
{
$this->line->sticker(1, 138)
->send('ข้อความ และ Sticker');

self::assertTrue(true);
}

public function test_disable_notification()
public function test_disable_notification(): void
{
$this->line->disableNotification()
->send('ข้อความไม่แจ้งเตือน');
Expand Down

0 comments on commit 9506a92

Please sign in to comment.