Skip to content

Commit 8acbbda

Browse files
koenhoeijmakersWebklex
authored andcommitted
replace helpers functions (#250)
1 parent d40033b commit 8acbbda

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/IMAP/Attachment.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace Webklex\IMAP;
1414

1515
use Illuminate\Support\Facades\File;
16+
use Illuminate\Support\Str;
1617
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
1718
use Webklex\IMAP\Exceptions\MaskNotFoundException;
1819
use Webklex\IMAP\Exceptions\MethodNotFoundException;
@@ -111,15 +112,15 @@ public function __construct(Message $oMessage, $structure, $part_number = 1) {
111112
*/
112113
public function __call($method, $arguments) {
113114
if(strtolower(substr($method, 0, 3)) === 'get') {
114-
$name = snake_case(substr($method, 3));
115+
$name = Str::snake(substr($method, 3));
115116

116117
if(isset($this->attributes[$name])) {
117118
return $this->attributes[$name];
118119
}
119120

120121
return null;
121122
}elseif (strtolower(substr($method, 0, 3)) === 'set') {
122-
$name = snake_case(substr($method, 3));
123+
$name = Str::snake(substr($method, 3));
123124

124125
$this->attributes[$name] = array_pop($arguments);
125126

@@ -336,4 +337,4 @@ public function mask($mask = null){
336337

337338
throw new MaskNotFoundException("Unknown mask provided: ".$mask);
338339
}
339-
}
340+
}

src/IMAP/Message.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace Webklex\IMAP;
1414

1515
use Carbon\Carbon;
16+
use Illuminate\Support\Str;
1617
use Webklex\IMAP\Exceptions\InvalidMessageDateException;
1718
use Webklex\IMAP\Exceptions\MaskNotFoundException;
1819
use Webklex\IMAP\Exceptions\MethodNotFoundException;
@@ -239,14 +240,14 @@ public function __construct($uid, $msglist, Client $client, $fetch_options = nul
239240
*/
240241
public function __call($method, $arguments) {
241242
if(strtolower(substr($method, 0, 3)) === 'get') {
242-
$name = snake_case(substr($method, 3));
243+
$name = Str::snake(substr($method, 3));
243244

244245
if(in_array($name, array_keys($this->attributes))) {
245246
return $this->attributes[$name];
246247
}
247248

248249
}elseif (strtolower(substr($method, 0, 3)) === 'set') {
249-
$name = snake_case(substr($method, 3));
250+
$name = Str::snake(substr($method, 3));
250251

251252
if(in_array($name, array_keys($this->attributes))) {
252253
$this->attributes[$name] = array_pop($arguments);

src/IMAP/Query/WhereQuery.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Webklex\IMAP\Query;
1414

15+
use Illuminate\Support\Str;
1516
use Webklex\IMAP\Exceptions\InvalidWhereQueryCriteriaException;
1617
use Webklex\IMAP\Exceptions\MethodNotFoundException;
1718
use Webklex\IMAP\Exceptions\MessageSearchValidationException;
@@ -73,7 +74,7 @@ class WhereQuery extends Query {
7374
public function __call($name, $arguments) {
7475
$that = $this;
7576

76-
$name = camel_case($name);
77+
$name = Str::camel($name);
7778

7879
if(strtolower(substr($name, 0, 3)) === 'not') {
7980
$that = $that->whereNot();
@@ -425,4 +426,4 @@ public function whereIsXSpam(){
425426
public function whereLanguage($country_code){
426427
return $this->where("Content-Language $country_code");
427428
}
428-
}
429+
}

src/IMAP/Support/Masks/Mask.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Webklex\IMAP\Support\Masks;
1414

15+
use Illuminate\Support\Str;
1516
use Webklex\IMAP\Exceptions\MethodNotFoundException;
1617

1718
/**
@@ -60,14 +61,14 @@ protected function boot(){}
6061
*/
6162
public function __call($method, $arguments) {
6263
if(strtolower(substr($method, 0, 3)) === 'get') {
63-
$name = snake_case(substr($method, 3));
64+
$name = Str::snake(substr($method, 3));
6465

6566
if(isset($this->attributes[$name])) {
6667
return $this->attributes[$name];
6768
}
6869

6970
}elseif (strtolower(substr($method, 0, 3)) === 'set') {
70-
$name = snake_case(substr($method, 3));
71+
$name = Str::snake(substr($method, 3));
7172

7273
if(isset($this->attributes[$name])) {
7374
$this->attributes[$name] = array_pop($arguments);
@@ -123,4 +124,4 @@ public function getAttributes(){
123124
return $this->attributes;
124125
}
125126

126-
}
127+
}

0 commit comments

Comments
 (0)