Skip to content

Commit

Permalink
fix styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alhelwany committed Aug 19, 2024
1 parent 2b86a03 commit 0cc6102
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/MTNClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class MTNClient

private HttpClient $httpClient;

private MessageEncoder $messageEncoder;
private MessageEncoder $messageEncoder;

public function __construct(string $url, string $username, string $password, string $from)
{
$this->phoneFormatter = new PhoneFormatter;
$this->httpClient = new HttpClient($url, $username, $password, $from);
$this->messageEncoder = new MessageEncoder;
$this->messageEncoder = new MessageEncoder;
}

/**
Expand Down
16 changes: 9 additions & 7 deletions src/Utilities/MessageEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

class MessageEncoder
{
public function __construct() {}
public function __construct() {}

public function encode(string $msg, Lang $lang)
{
if ($lang == Lang::AR)
return strtoupper(bin2hex(mb_convert_encoding($msg, 'UTF-16', 'UTF-8')));
return $msg;
}
public function encode(string $msg, Lang $lang)
{
if ($lang == Lang::AR) {
return strtoupper(bin2hex(mb_convert_encoding($msg, 'UTF-16', 'UTF-8')));
}

return $msg;
}
}
7 changes: 3 additions & 4 deletions tests/Unit/MessageEncoderTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?php

use Alhelwany\LaravelMtn\Enums\Lang;
use Alhelwany\LaravelMtn\Exceptions\InvalidPhoneNumberLengthException;
use Alhelwany\LaravelMtn\Utilities\MessageEncoder;

$messageEncoder = new MessageEncoder;

it('can encode arabic', function () use ($messageEncoder) {
$msg = "مرحبا";
$msg = 'مرحبا';
expect($messageEncoder->encode($msg, Lang::AR))->toBe('06450631062D06280627');
});

it('does not encode english', function () use ($messageEncoder) {
$msg = "hello";
$msg = 'hello';
expect($messageEncoder->encode($msg, Lang::EN))->toBe('hello');
});
});

0 comments on commit 0cc6102

Please sign in to comment.