Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix guzzle version for laravel 8 and added laravel 9 version #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea
/vendor
build
composer.phar
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/trello/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/trello/?branch=master)
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/trello.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/trello)

This package makes it easy to create [Trello cards](https://developers.trello.com/) with Laravel 6.x, 7.x & 8.x.
This package makes it easy to create [Trello cards](https://developers.trello.com/) with Laravel 6.x, 7.x, 8.x & 9.x.

## Contents

Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
"name": "Marcel Pociot",
"email": "[email protected]",
"homepage": "http://www.marcelpociot.com"
},
{
"name": "Jose Vicente Orts Romero",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.2.5",
"guzzlehttp/guzzle": "~6.0",
"illuminate/notifications": "~6.0 || ~7.0 || ~8.0",
"illuminate/support": "~6.0 || ~7.0 || ~8.0"
"guzzlehttp/guzzle": "~6.0 || ^7.0.1",
"illuminate/notifications": "~6.0 || ~7.0 || ~8.0 || ~9.0",
"illuminate/support": "~6.0 || ~7.0 || ~8.0 || ~9.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/CouldNotSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class CouldNotSendNotification extends \Exception
{
public static function serviceRespondedWithAnError($response)
public static function serviceRespondedWithAnError($response): static
{
return new static('Trello responded with an error: `'.$response->getBody()->getContents().'`');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class InvalidConfiguration extends \Exception
{
public static function configurationNotSet()
public static function configurationNotSet(): static
{
return new static('In order to send notification via Trello you need to add credentials in the `trello` key of `config.services`.');
}
Expand Down
10 changes: 6 additions & 4 deletions src/TrelloChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class TrelloChannel
{
const API_ENDPOINT = 'https://api.trello.com/1/cards/';
/** @var string */
public const API_ENDPOINT = 'https://api.trello.com/1/cards/';

/** @var Client */
protected $client;
Expand All @@ -24,13 +25,14 @@ public function __construct(Client $client)
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
*
* @throws \NotificationChannels\Trello\Exceptions\InvalidConfiguration
* @throws \NotificationChannels\Trello\Exceptions\CouldNotSendNotification
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function send($notifiable, Notification $notification)
public function send($notifiable, Notification $notification): void
{
if (! $routing = collect($notifiable->routeNotificationFor('Trello'))) {
return;
Expand Down
40 changes: 19 additions & 21 deletions src/TrelloMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NotificationChannels\Trello;

use DateTime;
use DateTimeInterface;

class TrelloMessage
{
Expand All @@ -19,31 +20,29 @@ class TrelloMessage
protected $due;

/**
* @param string $name
*
* @param string $name
* @return static
*/
public static function create($name = '')
public static function create(string $name = ''): TrelloMessage
{
return new static($name);
}

/**
* @param string $name
* @param string $name
*/
public function __construct($name = '')
public function __construct(string $name = '')
{
$this->name = $name;
}

/**
* Set the card name.
*
* @param $name
*
* @param string $name
* @return $this
*/
public function name($name)
public function name(string $name): TrelloMessage
{
$this->name = $name;

Expand All @@ -53,11 +52,10 @@ public function name($name)
/**
* Set the card description.
*
* @param $description
*
* @param string $description
* @return $this
*/
public function description($description)
public function description(string $description): TrelloMessage
{
$this->description = $description;

Expand All @@ -67,11 +65,10 @@ public function description($description)
/**
* Set the card position.
*
* @param string|int $position
*
* @param string|int $position
* @return $this
*/
public function position($position)
public function position(string $position): TrelloMessage
{
$this->position = $position;

Expand All @@ -83,7 +80,7 @@ public function position($position)
*
* @return $this
*/
public function top()
public function top(): TrelloMessage
{
$this->position = 'top';

Expand All @@ -95,7 +92,7 @@ public function top()
*
* @return $this
*/
public function bottom()
public function bottom(): TrelloMessage
{
$this->position = 'bottom';

Expand All @@ -105,25 +102,26 @@ public function bottom()
/**
* Set the card position due date.
*
* @param string|DateTime $due
*
* @param string|DateTime $due
* @return $this
*
* @throws \Exception
*/
public function due($due)
public function due($due): TrelloMessage
{
if (! $due instanceof DateTime) {
$due = new DateTime($due);
}

$this->due = $due->format(DateTime::ATOM);
$this->due = $due->format(DateTimeInterface::ATOM);

return $this;
}

/**
* @return array
*/
public function toArray()
public function toArray(): array
{
return [
'name' => $this->name,
Expand Down