Skip to content

Commit

Permalink
Use Illuminate\Support\Str instead of str_ (Fixes #26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Nov 14, 2019
1 parent 448d968 commit d187dcd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.1.4 (11-13-2019)

### Bug fixes
- Use `Illuminate\Support\Str` instead of `str_`

## v1.1.3 (08-25-2019)

### Enhancements
Expand Down
26 changes: 14 additions & 12 deletions src/Directives/ACF.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Log1x\SageDirectives;

use Illuminate\Support\Str;

return [

/*
Expand All @@ -20,7 +22,7 @@
*/

'fields' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'field' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'hasfield' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'isfield' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

if (! empty($expression->get(3)) && ! is_string($expression->get(2))) {
Expand Down Expand Up @@ -108,7 +110,7 @@
*/

'sub' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

if (! empty($expression->get(2))) {
Expand All @@ -122,7 +124,7 @@
},

'hassub' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

if (! empty($expression->get(2))) {
Expand All @@ -136,7 +138,7 @@
},

'issub' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'layouts' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'group' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'option' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'hasoption' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'isoption' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

if (! empty($expression->get(2))) {
Expand Down
18 changes: 10 additions & 8 deletions src/Directives/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Log1x\SageDirectives;

use Illuminate\Support\Str;

return [

/*
Expand All @@ -20,7 +22,7 @@
*/

'istrue' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'isfalse' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'isnull' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'isnotnull' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'instanceof' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'typeof' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'set' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

'implode' => function ($expression) {
if (str_contains($expression, ',')) {
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

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

0 comments on commit d187dcd

Please sign in to comment.