Skip to content

Commit

Permalink
Added contains as an alias for includes for both A and S
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed May 17, 2021
1 parent 2bfe4b8 commit 3b9b9cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ Plain numeric arrays are handled best via the methods in A, while associative ar
```

- **includes** -
- **contains** -

- **slice** -
- **join** -
- **pickRandom** - selects a random item from the given array
Expand Down Expand Up @@ -359,6 +361,8 @@ Plain numeric arrays are handled best via the methods in A, while associative ar
S::includes('', 'butterfly'); // false -- edge case
```

- **contains** - alias for S::includes()

- **split** - splits a string into multiple parts at points matching another string

```php
Expand Down
6 changes: 6 additions & 0 deletions src/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ public static function includes($value, array $data): bool
return in_array($value, $data, true);
}

// alias for A::includes
public static function contains($value, array $data): bool
{
return self::includes($value, $data);
}

// A::slice(2, 4, [1, 2, 3, 4, 5]) -> [3, 4, 5]
public static function slice(int $fromIndex, int $toIndex, array $data): array
{
Expand Down
6 changes: 6 additions & 0 deletions src/S.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public static function includes(string $str, string $data, $caseSensitivity = se
}
}

// alias for S::includes
public static function contains(string $str, string $data, $caseSensitivity = self::CASE_SENSITIVE): bool
{
return self::includes($str, $data, $caseSensitivity);
}

// S::split(' ', "aab bbc ccd") -> ['aab', 'bbc', 'ccd']
public static function split(string $separator, string $data): array
{
Expand Down

0 comments on commit 3b9b9cb

Please sign in to comment.