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

Revert renaming static factory method create to make #15

Merged
merged 1 commit into from
Apr 26, 2020
Merged
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
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ All notable changes to `laravel-notification-channels/rocket-chat` will be docum

- ([#7]) Method `channel` renamed to `getDefaultChannel` in `NotificationChannels\RocketChat\RocketChat` class
- ([#7]) Method `token` renamed to `getToken` in `NotificationChannels\RocketChat\RocketChat` class
- ([#7]) Method `create` renamed to `make` in `NotificationChannels\RocketChat\RocketChatMessage` class
- ([#7]) Method `create` renamed to `make` in `NotificationChannels\RocketChat\RocketChatAttachment` class
- ([#7]) Method `setFromArray` renamed to `setPropertiesFromArray` in `NotificationChannels\RocketChat\RocketChatAttachment` class

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TaskCompleted extends Notification

public function toRocketChat($notifiable): RocketChatMessage
{
return RocketChatMessage::make('Test message')
return RocketChatMessage::create('Test message')
->to('channel_name') // optional if set in config
->from('webhook_token'); // optional if set in config
}
Expand Down Expand Up @@ -118,12 +118,12 @@ There are several ways to add one ore more attachments to a message
```php
public function toRocketChat($notifiable)
{
return RocketChatMessage::make('Test message')
return RocketChatMessage::create('Test message')
->to('channel_name') // optional if set in config
->from('webhook_token') // optional if set in config
->attachments([
RocketChatAttachment::make()->imageUrl('test'),
RocketChatAttachment::make(['image_url' => 'test']),
RocketChatAttachment::create()->imageUrl('test'),
RocketChatAttachment::create(['image_url' => 'test']),
new RocketChatAttachment(['image_url' => 'test']),
[
'image_url' => 'test'
Expand Down
2 changes: 1 addition & 1 deletion src/RocketChatAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct(array $data = [])
* @param array $data
* @return \NotificationChannels\RocketChat\RocketChatAttachment
*/
public static function make(array $data = [])
public static function create(array $data = [])
{
return new self($data);
}
Expand Down
2 changes: 1 addition & 1 deletion src/RocketChatMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RocketChatMessage
* @param string $content
* @return static
*/
public static function make(string $content = ''): self
public static function create(string $content = ''): self
{
return new static($content);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/RocketChatAttachmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function it_can_accept_a_config_when_constructing_an_attachment(): void
/** @test */
public function it_can_accept_a_config_when_creating_an_attachment(): void
{
$attachment = RocketChatAttachment::make(['title' => 'test123']);
$attachment = RocketChatAttachment::create(['title' => 'test123']);

$this->assertEquals(['title' => 'test123'], $attachment->toArray());
}
Expand Down
10 changes: 5 additions & 5 deletions tests/RocketChatMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function it_can_accept_a_content_when_constructing_a_message(): void
/** @test */
public function it_can_accept_a_content_when_creating_a_message(): void
{
$message = RocketChatMessage::make('test-content');
$message = RocketChatMessage::create('test-content');

$this->assertSame(['text' => 'test-content'], $message->toArray());
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public function it_can_set_the_avatar(): void
/** @test */
public function it_can_set_attachment(): void
{
$attachment = RocketChatAttachment::make(['title' => 'test']);
$attachment = RocketChatAttachment::create(['title' => 'test']);
$message = (new RocketChatMessage())->attachment($attachment);

$this->assertSame($attachment->toArray(), $message->toArray()['attachments'][0]);
Expand All @@ -95,9 +95,9 @@ public function it_can_set_attachment_as_array(): void
public function it_can_set_multiple_attachments(): void
{
$message = (new RocketChatMessage())->attachments([
RocketChatAttachment::make(),
RocketChatAttachment::make(),
RocketChatAttachment::make(),
RocketChatAttachment::create(),
RocketChatAttachment::create(),
RocketChatAttachment::create(),
]);

$this->assertCount(3, $message->toArray()['attachments']);
Expand Down
6 changes: 3 additions & 3 deletions tests/RocketChatWebhookChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,22 @@ class TestNotification extends Notification
{
public function toRocketChat(): RocketChatMessage
{
return RocketChatMessage::make('hello')->from(':token')->to(':channel');
return RocketChatMessage::create('hello')->from(':token')->to(':channel');
}
}

class TestNotificationWithMissedChannel extends Notification
{
public function toRocketChat(): RocketChatMessage
{
return RocketChatMessage::make('hello')->from(':token');
return RocketChatMessage::create('hello')->from(':token');
}
}

class TestNotificationWithMissedFrom extends Notification
{
public function toRocketChat(): RocketChatMessage
{
return RocketChatMessage::make('hello')->to(':channel');
return RocketChatMessage::create('hello')->to(':channel');
}
}