Skip to content

Commit

Permalink
Apply fixes from StyleCI (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
frkcn authored Feb 17, 2020
1 parent 3de2912 commit 6bc44d2
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 86 deletions.
6 changes: 3 additions & 3 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
return [
'credentials' => [
'user_code' => env('NETGSM_USERCODE'),
'secret' => env('NETGSM_SECRET')
'secret' => env('NETGSM_SECRET'),
],
'defaults' => [
'language' => env('NETGSM_LANGUAGE', 'tr'),
'header' => env('NETGSM_HEADER', null),
'sms_sending_method' => env('NETGSM_SMS_SENDING_METHOD', 'xml')
]
'sms_sending_method' => env('NETGSM_SMS_SENDING_METHOD', 'xml'),
],
];
21 changes: 12 additions & 9 deletions src/AbstractNetgsmMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ abstract class AbstractNetgsmMessage
protected $message;

/**
* authorized data parameter
* authorized data parameter.
*
* @see https://www.netgsm.com.tr/dokuman/#http-get-sms-g%C3%B6nderme
* @see https://www.netgsm.com.tr/dokuman/#xml-post-sms-g%C3%B6nderme
Expand Down Expand Up @@ -132,7 +132,7 @@ abstract protected function createXmlPost(): string;
*/
public function setRecipients($recipients)
{
if (!is_array($recipients)) {
if (! is_array($recipients)) {
$this->recipients = explode(',', $recipients);
} else {
$this->recipients = $recipients;
Expand Down Expand Up @@ -202,11 +202,12 @@ public function getSendMethod(): string
*/
public function setSendMethod(string $sendMethod): self
{
if (!in_array($sendMethod, $this->sendMethods)) {
throw new Exception($sendMethod." method is not allowed");
if (! in_array($sendMethod, $this->sendMethods)) {
throw new Exception($sendMethod.' method is not allowed');
}

$this->sendMethod = $sendMethod;

return $this;
}

Expand All @@ -219,13 +220,13 @@ public function isAuthorizedData(): bool
}

/**
*
* @param bool $authorizedData
* @return AbstractNetgsmMessage
*/
public function setAuthorizedData(bool $authorizedData): AbstractNetgsmMessage
public function setAuthorizedData(bool $authorizedData): self
{
$this->authorizedData = $authorizedData;

return $this;
}

Expand All @@ -234,7 +235,7 @@ public function setAuthorizedData(bool $authorizedData): AbstractNetgsmMessage
*/
public function getUrl(): string
{
return $this->url."/".$this->getSendMethod();
return $this->url.'/'.$this->getSendMethod();
}

/**
Expand Down Expand Up @@ -300,6 +301,7 @@ public function setCredentials(array $credentials): self
public function setStartDate(Carbon $startDate): self
{
$this->startDate = $startDate;

return $this;
}

Expand All @@ -310,6 +312,7 @@ public function setStartDate(Carbon $startDate): self
public function setEndDate(Carbon $endDate): self
{
$this->endDate = $endDate;

return $this;
}

Expand Down Expand Up @@ -337,11 +340,11 @@ public function parseResponse(): self
{
$result = explode(' ', $this->getResponseContent());

if (!isset($result[0])) {
if (! isset($result[0])) {
throw new CouldNotSendNotification(CouldNotSendNotification::NETGSM_GENERAL_ERROR);
}

if (!in_array($result[0], self::SUCCESS_CODES)) {
if (! in_array($result[0], self::SUCCESS_CODES)) {
$message = $this->errorCodes[$result[0]];
throw new CouldNotSendNotification($message);
}
Expand Down
1 change: 0 additions & 1 deletion src/Exceptions/CouldNotSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class CouldNotSendNotification extends \Exception
const SYSTEM_ERROR = 'Sistem hatası.';
const NETGSM_GENERAL_ERROR = 'Netgsm responded with an error :';


/**
* Thrown when there's a bad request and an error is responded.
*
Expand Down
3 changes: 0 additions & 3 deletions src/Exceptions/IncorrectPhoneNumberFormatException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php


namespace TarfinLabs\Netgsm\Exceptions;


class IncorrectPhoneNumberFormatException extends \Exception
{

}
2 changes: 0 additions & 2 deletions src/Exceptions/ReportException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php


namespace TarfinLabs\Netgsm\Exceptions;

use Exception;

class ReportException extends Exception
{

}
5 changes: 2 additions & 3 deletions src/Netgsm.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct(Client $client, array $credentials = [], array $defa
public function sendSms(AbstractNetgsmMessage $netgsmMessage)
{
try {

$netgsmMessage
->setClient($this->client)
->setCredentials($this->credentials)
Expand Down Expand Up @@ -80,10 +79,10 @@ public function getReports(

if (count($filters) > 0) {
foreach ($filters as $filter => $value) {
if (!method_exists($report, 'set'.$filter)) {
if (! method_exists($report, 'set'.$filter)) {
continue;
}

call_user_func([$report, 'set'.$filter], $value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/NetgsmChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function send($notifiable, Notification $notification)
{
$message = $notification->toNetgsm($notifiable);

if (!$message instanceof AbstractNetgsmMessage) {
if (! $message instanceof AbstractNetgsmMessage) {
throw new \Exception('Geçerli bir Netgsm mesajı değil');
}

Expand Down
4 changes: 1 addition & 3 deletions src/NetgsmOtpMessage.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace TarfinLabs\Netgsm;


use TarfinLabs\Netgsm\Exceptions\CouldNotSendNotification;

class NetgsmOtpMessage extends AbstractNetgsmMessage
Expand All @@ -26,7 +24,7 @@ class NetgsmOtpMessage extends AbstractNetgsmMessage
'password',
'msgheader',
'msg',
'no'
'no',
];

/**
Expand Down
3 changes: 0 additions & 3 deletions src/NetgsmReportInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php


namespace TarfinLabs\Netgsm;


interface NetgsmReportInterface
{

}
14 changes: 7 additions & 7 deletions src/NetgsmSmsDetailReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class NetgsmSmsDetailReport extends AbstractNetgsmReport
* @var array
*/
protected $errorCodes = [
30, 60, 65, 70
30, 60, 65, 70,
];

/**
* @var array
*/
protected $noResultCodes = [
100, 101
100, 101,
];

/**
Expand All @@ -34,14 +34,14 @@ class NetgsmSmsDetailReport extends AbstractNetgsmReport
protected $paginated = true;

/**
* Default filter parameters
* Default filter parameters.
*
* @var array
*/
protected $filters = [
'type' => 1,
'version' => 1,
'view' => 2
'view' => 2,
];

/**
Expand All @@ -62,21 +62,21 @@ public function setBulkId($bulkId): AbstractNetgsmReport
}

/**
* Processes the report line
* Processes the report line.
*
* @param $line
* @return array
*/
public function processRow($line): array
{
return [
'jobId' => (integer) $line->msginfo->jobID,
'jobId' => (int) $line->msginfo->jobID,
'message' => (string) $line->msginfo->msg,
'startDate' => (string) $line->datetime->startdate,
'endDate' => (string) $line->datetime->stopdate,
'status' => (string) $line->msginfo->state,
'total' => (string) $line->msginfo->total,
'header' => (string) $line->msginfo->msgheader
'header' => (string) $line->msginfo->msgheader,
];
}

Expand Down
12 changes: 5 additions & 7 deletions src/NetgsmSmsMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NetgsmSmsMessage extends AbstractNetgsmMessage
'20' => CouldNotSendNotification::MESSAGE_TOO_LONG,
'30' => CouldNotSendNotification::CREDENTIALS_INCORRECT,
'40' => CouldNotSendNotification::SENDER_INCORRECT,
'70' => CouldNotSendNotification::PARAMETERS_INCORRECT
'70' => CouldNotSendNotification::PARAMETERS_INCORRECT,
];

protected $fields = [
Expand All @@ -24,7 +24,7 @@ class NetgsmSmsMessage extends AbstractNetgsmMessage
'startdate',
'stopdate',
'dil',
'izin'
'izin',
];

/**
Expand Down Expand Up @@ -63,11 +63,9 @@ protected function mappers(): array
'usercode' => $this->credentials['user_code'],
'password' => $this->credentials['secret'],
'message' => $this->message,
'startdate' => !empty($this->startDate) ? $this->startDate->format('dmYHi') : null,
'stopdate' => !empty($this->endDate) ? $this->endDate->format('dmYHi') : null,
'izin' => (int) $this->isAuthorizedData()
'startdate' => ! empty($this->startDate) ? $this->startDate->format('dmYHi') : null,
'stopdate' => ! empty($this->endDate) ? $this->endDate->format('dmYHi') : null,
'izin' => (int) $this->isAuthorizedData(),
];
}


}
20 changes: 9 additions & 11 deletions src/NetgsmSmsReport.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace TarfinLabs\Netgsm;


use Illuminate\Support\Collection;

class NetgsmSmsReport extends AbstractNetgsmReport
Expand All @@ -14,21 +12,21 @@ class NetgsmSmsReport extends AbstractNetgsmReport
* @var array
*/
protected $errorCodes = [
30, 70, 100, 101
30, 70, 100, 101,
];

/**
* @var array
*/
protected $noResultCodes = [
60
60,
];
/**
* @var array
*/
protected $filters = [
'type' => 2,
'version' => 2
'version' => 2,
];

/**
Expand All @@ -38,12 +36,12 @@ class NetgsmSmsReport extends AbstractNetgsmReport
0 => [
'jobId' => 'integer',
'phone' => 'string',
'status' => 'integer'
'status' => 'integer',
],
1 => [
'jobId' => 'integer',
'phone' => 'string',
'status' => 'integer'
'status' => 'integer',
],
2 => [
'jobId' => 'integer',
Expand All @@ -53,13 +51,13 @@ class NetgsmSmsReport extends AbstractNetgsmReport
'length' => 'integer',
'startDate' => 'date',
'startTime' => 'date',
'errorCode' => 'integer'
'errorCode' => 'integer',
],
3 => [
'jobId' => 'integer',
'phone' => 'string',
'status' => 'integer'
]
'status' => 'integer',
],
];

/**
Expand All @@ -73,7 +71,7 @@ class NetgsmSmsReport extends AbstractNetgsmReport
'length' => null,
'startDate' => null,
'startTime' => null,
'errorCode' => null
'errorCode' => null,
];

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/NetGsmChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setUp(): void

$this->netgsm = Mockery::mock(new Netgsm($this->httpClient, [
'userCode' => '',
'secret' => ''
'secret' => '',
]));

$this->channel = new NetGsmChannel($this->netgsm);
Expand Down
Loading

0 comments on commit 6bc44d2

Please sign in to comment.