Skip to content

Commit 12d3da0

Browse files
Merge pull request #15 from laravel-notification-channels/v3
2 parents dc65de8 + 7bdce82 commit 12d3da0

12 files changed

+141
-164
lines changed

Diff for: .github/workflows/php-cs-fixer.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check & fix styling
2+
3+
on: [push]
4+
5+
jobs:
6+
php-cs-fixer:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.head_ref }}
14+
15+
- name: Run PHP CS Fixer
16+
uses: docker://oskarstark/php-cs-fixer-ga
17+
with:
18+
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
19+
20+
- name: Commit changes
21+
uses: stefanzweifel/git-auto-commit-action@v4
22+
with:
23+
commit_message: Fix styling

Diff for: .github/workflows/run-tests.yml

+7-12
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@ jobs:
88
strategy:
99
fail-fast: true
1010
matrix:
11-
os: [ubuntu-latest, windows-latest]
12-
php: [7.4]
13-
laravel: [8.*, 5.8.*, 6.*, 7.*]
11+
os: [ubuntu-latest]
12+
php: [8.1]
13+
laravel: [9.*]
1414
dependency-version: [prefer-lowest, prefer-stable]
1515
include:
16-
- laravel: 8.*
17-
testbench: 6.*
18-
- laravel: 7.*
19-
testbench: 5.*
20-
- laravel: 6.*
21-
testbench: 4.*
22-
- laravel: 5.8.*
23-
testbench: 3.8.*
16+
- laravel: 9.*
17+
testbench: 7.*
2418

2519
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
2620

@@ -38,12 +32,13 @@ jobs:
3832
uses: shivammathur/setup-php@v2
3933
with:
4034
php-version: ${{ matrix.php }}
41-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
35+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
4236
coverage: none
4337

4438
- name: Install dependencies
4539
run: |
4640
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
4741
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
42+
4843
- name: Execute tests
4944
run: vendor/bin/phpunit

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ build
33
composer.phar
44
composer.lock
55
.phpunit.result.cache
6+
.php-cs-fixer.cache

Diff for: .php-cs-fixer.dist.php

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
6+
$finder = Finder::create()
7+
->in([
8+
__DIR__ . '/src',
9+
__DIR__ . '/tests',
10+
])
11+
->notPath('bootstrap/*')
12+
->notPath('storage/*')
13+
->notPath('resources/view/mail/*')
14+
->name('*.php')
15+
->notName('*.blade.php')
16+
->ignoreDotFiles(true)
17+
->ignoreVCS(true)
18+
;
19+
20+
return (new Config())
21+
->setRules([
22+
'@PSR12' => true,
23+
'array_syntax' => ['syntax' => 'short'],
24+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
25+
'no_unused_imports' => true,
26+
'not_operator_with_successor_space' => true,
27+
'trailing_comma_in_multiline' => true,
28+
'phpdoc_scalar' => true,
29+
'unary_operator_spaces' => true,
30+
'binary_operator_spaces' => true,
31+
'blank_line_before_statement' => [
32+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
33+
],
34+
'phpdoc_single_line_var_spacing' => true,
35+
'phpdoc_var_without_name' => true,
36+
'class_attributes_separation' => [
37+
'elements' => [
38+
'method' => 'one',
39+
],
40+
],
41+
'method_argument_space' => [
42+
'on_multiline' => 'ensure_fully_multiline',
43+
'keep_multiple_spaces_after_comma' => true,
44+
],
45+
'single_trait_insert_per_statement' => true,
46+
])
47+
->setFinder($finder);

Diff for: CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to `CMSMS` will be documented in this file
44

5+
## [3.0.0] - 2020-09-09
6+
#### Changed
7+
- General cleanup of package. Added return types.
8+
- Added support for Laravel 9.0
9+
- Added support for PHP 8.1
10+
- Dropped support for Laravel 8 and below.
11+
- Dropped support for PHP 8.0 and below.
12+
513
## [2.2.0] - 2020-09-09
614
#### Changed
715
- Added support for Laravel 8.0

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CMSMS notifications channel for Laravel
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/cmsms.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/cmsms)
4-
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/laravel-notification-channels/cmsms/run-tests?label=tests)
4+
[![run-tests](https://github.com/laravel-notification-channels/cmsms/actions/workflows/run-tests.yml/badge.svg)](https://github.com/laravel-notification-channels/cmsms/actions/workflows/run-tests.yml)
55
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/cmsms.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/cmsms)
66

77
This package makes it easy to send [CMSMS messages](https://docs.cmtelecom.com/en/api/business-messaging-api/1.0/index) with Laravel.

Diff for: composer.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^7.2",
15+
"php": "^8.1",
1616
"ext-simplexml": "*",
17-
"guzzlehttp/guzzle": "^6.2|^7.0",
18-
"illuminate/notifications": "~5.8 || ~6.0 || ^7.0 || ^8.0",
19-
"illuminate/support": "~5.8 || ~6.0 || ^7.0 || ^8.0",
20-
"orchestra/testbench": "~3.8.0 || ^4.0 || ^5.0 || ^6.0"
17+
"guzzlehttp/guzzle": "^7.1",
18+
"illuminate/notifications": "^9.0",
19+
"illuminate/support": "^9.0"
2120
},
2221
"require-dev": {
23-
"mockery/mockery": "~1.3.1",
24-
"phpunit/phpunit": "~8.0"
22+
"friendsofphp/php-cs-fixer": "^3.6",
23+
"mockery/mockery": "^1.5",
24+
"orchestra/testbench": "^7.0",
25+
"phpunit/phpunit": "^9.5"
2526
},
2627
"config": {
2728
"sort-packages": true
@@ -46,6 +47,8 @@
4647
"minimum-stability": "dev",
4748
"prefer-stable": true,
4849
"scripts": {
49-
"test": "vendor/bin/phpunit"
50+
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
51+
"test": "vendor/bin/phpunit",
52+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
5053
}
5154
}

Diff for: phpunit.xml.dist

+11-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
12-
<testsuites>
13-
<testsuite name="CmsmsChannel Test Suite">
14-
<directory>tests</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="CmsmsChannel Test Suite">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
2213
</phpunit>

Diff for: src/CmsmsChannel.php

+5-19
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,14 @@
88

99
class CmsmsChannel
1010
{
11-
/** @var CmsmsClient */
12-
protected $client;
13-
14-
/**
15-
* @param CmsmsClient $client
16-
*/
17-
public function __construct(CmsmsClient $client)
18-
{
19-
$this->client = $client;
11+
public function __construct(
12+
protected CmsmsClient $client,
13+
) {
2014
}
2115

22-
/**
23-
* Send the given notification.
24-
*
25-
* @param mixed $notifiable
26-
* @param \Illuminate\Notifications\Notification $notification
27-
*
28-
* @throws \NotificationChannels\Cmsms\Exceptions\CouldNotSendNotification
29-
*/
30-
public function send($notifiable, Notification $notification)
16+
public function send($notifiable, Notification $notification): void
3117
{
32-
if (!$recipient = $notifiable->routeNotificationFor('Cmsms')) {
18+
if (! $recipient = $notifiable->routeNotificationFor('Cmsms')) {
3319
return;
3420
}
3521

Diff for: src/CmsmsClient.php

+8-30
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,22 @@
1111

1212
class CmsmsClient
1313
{
14-
const GATEWAY_URL = 'https://sgw01.cm.nl/gateway.ashx';
14+
public const GATEWAY_URL = 'https://sgw01.cm.nl/gateway.ashx';
1515

16-
/** @var GuzzleClient */
17-
protected $client;
18-
19-
/** @var string */
20-
protected $productToken;
21-
22-
/**
23-
* @param GuzzleClient $client
24-
* @param string $productToken
25-
*/
26-
public function __construct(GuzzleClient $client, string $productToken)
27-
{
28-
$this->client = $client;
29-
$this->productToken = $productToken;
16+
public function __construct(
17+
protected GuzzleClient $client,
18+
protected string $productToken,
19+
) {
3020
}
3121

32-
/**
33-
* @param CmsmsMessage $message
34-
* @param string $recipient
35-
*
36-
* @throws CouldNotSendNotification
37-
*/
38-
public function send(CmsmsMessage $message, string $recipient)
22+
public function send(CmsmsMessage $message, string $recipient): void
3923
{
4024
if (is_null(Arr::get($message->toXmlArray(), 'FROM'))) {
4125
$message->originator(config('services.cmsms.originator'));
4226
}
4327

4428
$response = $this->client->request('POST', static::GATEWAY_URL, [
45-
'body' => $this->buildMessageXml($message, $recipient),
29+
'body' => $this->buildMessageXml($message, $recipient),
4630
'headers' => [
4731
'Content-Type' => 'application/xml',
4832
],
@@ -51,17 +35,11 @@ public function send(CmsmsMessage $message, string $recipient)
5135
// API returns an empty string on success
5236
// On failure, only the error string is passed
5337
$body = $response->getBody()->getContents();
54-
if (!empty($body)) {
38+
if (! empty($body)) {
5539
throw CouldNotSendNotification::serviceRespondedWithAnError($body);
5640
}
5741
}
5842

59-
/**
60-
* @param CmsmsMessage $message
61-
* @param string $recipient
62-
*
63-
* @return string
64-
*/
6543
public function buildMessageXml(CmsmsMessage $message, string $recipient): string
6644
{
6745
$xml = new SimpleXMLElement('<MESSAGES/>');

0 commit comments

Comments
 (0)