Skip to content

Commit d000cc0

Browse files
committed
Utility: update README.md
- Move `.env` file syntax documentation to `docs` - Reinstate/refresh utility class summaries
1 parent c64322f commit d000cc0

File tree

11 files changed

+100
-32
lines changed

11 files changed

+100
-32
lines changed

docs/Env.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Environment variables
2+
3+
## `.env` file syntax
4+
5+
Non-empty lines in a `.env` file may contain either a shell-compatible variable
6+
assignment (see below for limitations) or a comment.
7+
8+
Example:
9+
10+
```shell
11+
LANG=en_US.UTF-8
12+
TZ=Australia/Sydney
13+
14+
# app_secret is parsed as: '^K&4nnE
15+
app_client_id=d8f024b9-1dfb-4dde-8f29-db98eefa317c
16+
app_secret=''\''^K&4nnE'
17+
```
18+
19+
- Unquoted values cannot contain unescaped whitespace, `"`, `'`, `$`, backticks,
20+
or glob characters (`*`, `?`, `[`, `]`).
21+
- Quoted values must be fully enclosed by one pair of single or double quotes.
22+
- Double-quoted values cannot contain `"`, `$`, or backticks unless they are
23+
escaped.
24+
- Single-quoted values may contain single quotes if this syntax is used: `'\''`
25+
- Variable expansion and command substitution are not supported.
26+
- Comment lines must start with `#`.

src/Toolkit/Utility/Arr.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Stringable;
99

1010
/**
11+
* Work with arrays and iterables
12+
*
1113
* @api
1214
*/
1315
final class Arr extends AbstractUtility

src/Toolkit/Utility/Date.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use InvalidArgumentException;
1010

1111
/**
12+
* Work with date and time values, timezones and intervals
13+
*
1214
* @api
1315
*/
1416
final class Date extends AbstractUtility

src/Toolkit/Utility/Debug.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Salient\Utility;
44

55
/**
6+
* Get information about the call stack
7+
*
68
* @api
79
*/
810
final class Debug extends AbstractUtility

src/Toolkit/Utility/Env.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,7 @@
99
use RuntimeException;
1010

1111
/**
12-
* Work with .env files and environment variables
13-
*
14-
* Non-empty lines in a `.env` file may contain either a shell-compatible
15-
* variable assignment (see below for limitations) or a comment.
16-
*
17-
* Example:
18-
*
19-
* ```shell
20-
* LANG=en_US.UTF-8
21-
* TZ=Australia/Sydney
22-
*
23-
* # app_secret is parsed as: '^K&4nnE
24-
* app_client_id=d8f024b9-1dfb-4dde-8f29-db98eefa317c
25-
* app_secret=''\''^K&4nnE'
26-
* ```
27-
*
28-
* - Unquoted values cannot contain unescaped whitespace, `"`, `'`, `$`,
29-
* backticks, or glob characters (`*`, `?`, `[`, `]`).
30-
* - Quoted values must be fully enclosed by one pair of single or double
31-
* quotes.
32-
* - Double-quoted values cannot contain `"`, `$`, or backticks unless they are
33-
* escaped.
34-
* - Single-quoted values may contain single quotes if this syntax is used:
35-
* `'\''`
36-
* - Variable expansion and command substitution are not supported.
37-
* - Comment lines must start with `#`.
12+
* Work with environment variables and .env files
3813
*
3914
* {@see Env::get()}, {@see Env::getInt()}, etc. check `$_ENV`, `$_SERVER` and
4015
* {@see getenv()} for a given variable and return the first value found. If the

src/Toolkit/Utility/Format.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use JsonException;
99

1010
/**
11-
* Format data for humans
11+
* Make data human-readable
1212
*
1313
* @api
1414
*/

src/Toolkit/Utility/Inflect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Traversable;
1010

1111
/**
12-
* Inflect English words
12+
* Convert English words to different forms
1313
*
1414
* @api
1515
*/

src/Toolkit/Utility/Json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Salient\Utility;
44

55
/**
6-
* Wrappers for json_encode() and json_decode()
6+
* Wrappers for json_encode() and json_decode() that throw exceptions on failure
77
*
88
* @api
99
*/

src/Toolkit/Utility/README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# salient/utils
22

3-
> The utilities component of the [Salient toolkit][toolkit]
3+
> The utils component of the [Salient toolkit][toolkit]
44
55
<p>
66
<a href="https://packagist.org/packages/salient/toolkit"><img src="https://poser.pugx.org/salient/toolkit/v" alt="Latest Stable Version" /></a>
@@ -11,4 +11,64 @@
1111

1212
---
1313

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
1474
[toolkit]: https://github.com/salient-labs/toolkit

src/Toolkit/Utility/Regex.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
use Stringable;
77

88
/**
9-
* Wrappers for PHP's regular expression functions
9+
* Wrappers for PHP's regular expression functions that throw exceptions on
10+
* failure
1011
*
1112
* @api
1213
*/

0 commit comments

Comments
 (0)