|
1 | 1 | # salient/utils |
2 | 2 |
|
3 | | -> The utilities component of the [Salient toolkit][toolkit] |
| 3 | +> The utils component of the [Salient toolkit][toolkit] |
4 | 4 |
|
5 | 5 | <p> |
6 | 6 | <a href="https://packagist.org/packages/salient/toolkit"><img src="https://poser.pugx.org/salient/toolkit/v" alt="Latest Stable Version" /></a> |
|
11 | 11 |
|
12 | 12 | --- |
13 | 13 |
|
| 14 | +`salient/utils` provides a suite of useful utility methods via the following |
| 15 | +stateless classes. |
| 16 | + |
| 17 | +- **`Arr`** works with arrays and iterables. |
| 18 | + |
| 19 | +- **`Date`** works with date and time values, timezones and intervals. |
| 20 | + |
| 21 | +- **`Debug`** gets caller information by normalising backtrace data. |
| 22 | + |
| 23 | +- **`Env`** retrieves environment variables, loads values from `.env` files, and |
| 24 | + applies values from the environment to the script. |
| 25 | + |
| 26 | +- **`File`** provides methods for filesystem operations that throw exceptions on |
| 27 | + failure. |
| 28 | + |
| 29 | +- **`Format`** makes data human-readable. |
| 30 | + |
| 31 | +- **`Get`** extracts, converts and generates data. For example: |
| 32 | + |
| 33 | + - `Get::coalesce()` replicates the SQL `COALESCE()` function |
| 34 | + - `Get::code()` improves upon `var_export()` |
| 35 | + - `Get::copy()` gets a deep copy of an object |
| 36 | + - `Get::eol()` gets a string's end-of-line sequence |
| 37 | + - `Get::uuid()` generates or converts a UUID |
| 38 | + |
| 39 | +- **`Inflect`** converts English words to different forms, e.g. from singular to |
| 40 | + plural. |
| 41 | + |
| 42 | +- **`Json`** provides methods for encoding and decoding JSON data that throw |
| 43 | + exceptions on failure. |
| 44 | + |
| 45 | +- **`Package`** retrieves information from Composer's runtime API, e.g. the name |
| 46 | + of the root package. |
| 47 | + |
| 48 | +- **`Reflect`** works with PHP's reflection API. |
| 49 | + |
| 50 | +- **`Regex`** provides methods for working with regular expressions that throw |
| 51 | + exceptions on failure. |
| 52 | + |
| 53 | +- **`Str`** manipulates strings. For example: |
| 54 | + |
| 55 | + - `Str::expandLeadingTabs()` expands leading tabs to spaces |
| 56 | + - `Str::matchCase()` matches the case of one string to another |
| 57 | + - `Str::ngrams()` gets a string's n-grams |
| 58 | + - `Str::splitDelimited()` safely splits strings that contain delimiters |
| 59 | + - `Str::toSnakeCase()` converts a string to snake_case |
| 60 | + |
| 61 | +- **`Sys`** retrieves information about the runtime environment, and provides a |
| 62 | + handler for exit signals (`SIGTERM`, `SIGINT` and `SIGHUP`). |
| 63 | + |
| 64 | +- **`Test`** performs tests on values. |
| 65 | + |
| 66 | +## Documentation |
| 67 | + |
| 68 | +[API documentation][api-docs] for `salient/utils` tracks the `main` branch of |
| 69 | +the toolkit's [GitHub repository][toolkit], where further documentation can also |
| 70 | +be found. |
| 71 | + |
| 72 | +[api-docs]: |
| 73 | + https://salient-labs.github.io/toolkit/namespace-Salient.Utility.html |
14 | 74 | [toolkit]: https://github.com/salient-labs/toolkit |
0 commit comments