Skip to content

Commit d187dcd

Browse files
committed
Use Illuminate\Support\Str instead of str_ (Fixes #26)
1 parent 448d968 commit d187dcd

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v1.1.4 (11-13-2019)
2+
3+
### Bug fixes
4+
- Use `Illuminate\Support\Str` instead of `str_`
5+
16
## v1.1.3 (08-25-2019)
27

38
### Enhancements

src/Directives/ACF.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Log1x\SageDirectives;
44

5+
use Illuminate\Support\Str;
6+
57
return [
68

79
/*
@@ -20,7 +22,7 @@
2022
*/
2123

2224
'fields' => function ($expression) {
23-
if (str_contains($expression, ',')) {
25+
if (Str::contains($expression, ',')) {
2426
$expression = Util::parse($expression);
2527

2628
return "<?php if (have_rows({$expression->get(0)}, {$expression->get(1)})) : ?>" .
@@ -42,7 +44,7 @@
4244
*/
4345

4446
'field' => function ($expression) {
45-
if (str_contains($expression, ',')) {
47+
if (Str::contains($expression, ',')) {
4648
$expression = Util::parse($expression);
4749

4850
if (! empty($expression->get(2)) && ! is_string($expression->get(2))) {
@@ -60,7 +62,7 @@
6062
},
6163

6264
'hasfield' => function ($expression) {
63-
if (str_contains($expression, ',')) {
65+
if (Str::contains($expression, ',')) {
6466
$expression = Util::parse($expression);
6567

6668
if (! empty($expression->get(2)) && ! is_string($expression->get(2))) {
@@ -78,7 +80,7 @@
7880
},
7981

8082
'isfield' => function ($expression) {
81-
if (str_contains($expression, ',')) {
83+
if (Str::contains($expression, ',')) {
8284
$expression = Util::parse($expression);
8385

8486
if (! empty($expression->get(3)) && ! is_string($expression->get(2))) {
@@ -108,7 +110,7 @@
108110
*/
109111

110112
'sub' => function ($expression) {
111-
if (str_contains($expression, ',')) {
113+
if (Str::contains($expression, ',')) {
112114
$expression = Util::parse($expression);
113115

114116
if (! empty($expression->get(2))) {
@@ -122,7 +124,7 @@
122124
},
123125

124126
'hassub' => function ($expression) {
125-
if (str_contains($expression, ',')) {
127+
if (Str::contains($expression, ',')) {
126128
$expression = Util::parse($expression);
127129

128130
if (! empty($expression->get(2))) {
@@ -136,7 +138,7 @@
136138
},
137139

138140
'issub' => function ($expression) {
139-
if (str_contains($expression, ',')) {
141+
if (Str::contains($expression, ',')) {
140142
$expression = Util::parse($expression);
141143

142144
if (! empty($expression->get(2))) {
@@ -158,7 +160,7 @@
158160
*/
159161

160162
'layouts' => function ($expression) {
161-
if (str_contains($expression, ',')) {
163+
if (Str::contains($expression, ',')) {
162164
$expression = Util::parse($expression);
163165

164166
return "<?php if (have_rows({$expression->get(0)}, {$expression->get(1)})) : ?>" .
@@ -194,7 +196,7 @@
194196
*/
195197

196198
'group' => function ($expression) {
197-
if (str_contains($expression, ',')) {
199+
if (Str::contains($expression, ',')) {
198200
$expression = Util::parse($expression);
199201

200202
return "<?php if (have_rows({$expression->get(0)}, {$expression->get(1)})) : ?>" .
@@ -231,7 +233,7 @@
231233
*/
232234

233235
'option' => function ($expression) {
234-
if (str_contains($expression, ',')) {
236+
if (Str::contains($expression, ',')) {
235237
$expression = Util::parse($expression);
236238

237239
return "<?= get_field({$expression->get(0)}, 'option')[{$expression->get(1)}]; ?>";
@@ -241,7 +243,7 @@
241243
},
242244

243245
'hasoption' => function ($expression) {
244-
if (str_contains($expression, ',')) {
246+
if (Str::contains($expression, ',')) {
245247
$expression = Util::parse($expression);
246248

247249
return "<?php if (get_field({$expression->get(0)}, 'option')[{$expression->get(1)}]) : ?>";
@@ -251,7 +253,7 @@
251253
},
252254

253255
'isoption' => function ($expression) {
254-
if (str_contains($expression, ',')) {
256+
if (Str::contains($expression, ',')) {
255257
$expression = Util::parse($expression);
256258

257259
if (! empty($expression->get(2))) {

src/Directives/Helpers.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Log1x\SageDirectives;
44

5+
use Illuminate\Support\Str;
6+
57
return [
68

79
/*
@@ -20,7 +22,7 @@
2022
*/
2123

2224
'istrue' => function ($expression) {
23-
if (str_contains($expression, ',')) {
25+
if (Str::contains($expression, ',')) {
2426
$expression = Util::parse($expression);
2527

2628
return "<?php if (isset({$expression->get(0)}) && (bool) {$expression->get(0)} === true) : ?>" .
@@ -36,7 +38,7 @@
3638
},
3739

3840
'isfalse' => function ($expression) {
39-
if (str_contains($expression, ',')) {
41+
if (Str::contains($expression, ',')) {
4042
$expression = Util::parse($expression);
4143

4244
return "<?php if (isset({$expression->get(0)}) && (bool) {$expression->get(0)} === false) : ?>" .
@@ -58,7 +60,7 @@
5860
*/
5961

6062
'isnull' => function ($expression) {
61-
if (str_contains($expression, ',')) {
63+
if (Str::contains($expression, ',')) {
6264
$expression = Util::parse($expression);
6365

6466
return "<?php if (is_null({$expression->get(0)})) : ?>" .
@@ -74,7 +76,7 @@
7476
},
7577

7678
'isnotnull' => function ($expression) {
77-
if (str_contains($expression, ',')) {
79+
if (Str::contains($expression, ',')) {
7880
$expression = Util::parse($expression);
7981

8082
return "<?php if (! is_null({$expression->get(0)})) : ?>" .
@@ -96,7 +98,7 @@
9698
*/
9799

98100
'instanceof' => function ($expression) {
99-
if (str_contains($expression, ',')) {
101+
if (Str::contains($expression, ',')) {
100102
$expression = Util::parse($expression);
101103

102104
return "<?php if ({$expression->get(0)} instanceof {$expression->get(1)}) : ?>";
@@ -114,7 +116,7 @@
114116
*/
115117

116118
'typeof' => function ($expression) {
117-
if (str_contains($expression, ',')) {
119+
if (Str::contains($expression, ',')) {
118120
$expression = Util::parse($expression);
119121

120122
return "<?php if (gettype({$expression->get(0)}) == {$expression->get(1)}) : ?>";
@@ -142,7 +144,7 @@
142144
*/
143145

144146
'set' => function ($expression) {
145-
if (str_contains($expression, ',')) {
147+
if (Str::contains($expression, ',')) {
146148
$expression = Util::parse($expression);
147149

148150
return "<?php {$expression->get(0)} = {$expression->get(1)}; ?>";
@@ -164,7 +166,7 @@
164166
},
165167

166168
'implode' => function ($expression) {
167-
if (str_contains($expression, ',')) {
169+
if (Str::contains($expression, ',')) {
168170
$expression = Util::parse($expression);
169171

170172
return "<?= implode({$expression->get(0)}, {$expression->get(1)}); ?>";

0 commit comments

Comments
 (0)