create-berna-stencil 2.0.7 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eleventy.js +38 -19
- package/README.md +2 -1
- package/bin/create.js +2 -2
- package/docs/Components.md +12 -0
- package/docs/Creating pages.md +3 -4
- package/docs/Head and SEO.md +7 -7
- package/package.json +63 -61
- package/src/backend/_core/vendor/composer/autoload_static.php +10 -10
- package/src/backend/_core/vendor/composer/installed.json +6 -6
- package/src/backend/_core/vendor/composer/installed.php +2 -2
- package/src/backend/_core/vendor/graham-campbell/result-type/LICENSE +21 -21
- package/src/backend/_core/vendor/graham-campbell/result-type/composer.json +33 -33
- package/src/backend/_core/vendor/graham-campbell/result-type/src/Error.php +121 -121
- package/src/backend/_core/vendor/graham-campbell/result-type/src/Result.php +69 -69
- package/src/backend/_core/vendor/graham-campbell/result-type/src/Success.php +120 -120
- package/src/backend/_core/vendor/phpoption/phpoption/LICENSE +200 -200
- package/src/backend/_core/vendor/phpoption/phpoption/composer.json +50 -50
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +175 -175
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/None.php +136 -136
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Option.php +434 -434
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Some.php +169 -169
- package/src/backend/_core/vendor/symfony/polyfill-ctype/Ctype.php +232 -232
- package/src/backend/_core/vendor/symfony/polyfill-ctype/LICENSE +19 -19
- package/src/backend/_core/vendor/symfony/polyfill-ctype/README.md +12 -12
- package/src/backend/_core/vendor/symfony/polyfill-ctype/bootstrap.php +50 -50
- package/src/backend/_core/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -46
- package/src/backend/_core/vendor/symfony/polyfill-ctype/composer.json +38 -38
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/LICENSE +19 -19
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Mbstring.php +1077 -1077
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/README.md +13 -13
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +119 -119
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +1397 -1397
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +5 -5
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +1489 -1489
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap.php +171 -171
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap80.php +167 -167
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/composer.json +39 -39
- package/src/backend/_core/vendor/symfony/polyfill-php80/LICENSE +19 -19
- package/src/backend/_core/vendor/symfony/polyfill-php80/Php80.php +115 -115
- package/src/backend/_core/vendor/symfony/polyfill-php80/PhpToken.php +106 -106
- package/src/backend/_core/vendor/symfony/polyfill-php80/README.md +25 -25
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +31 -31
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +16 -16
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +20 -20
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +16 -16
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +16 -16
- package/src/backend/_core/vendor/symfony/polyfill-php80/bootstrap.php +42 -42
- package/src/backend/_core/vendor/symfony/polyfill-php80/composer.json +37 -37
- package/src/backend/_core/vendor/vlucas/phpdotenv/LICENSE +30 -30
- package/src/backend/_core/vendor/vlucas/phpdotenv/composer.json +60 -60
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Dotenv.php +267 -267
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Loader.php +48 -48
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +20 -20
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +65 -65
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Entry.php +59 -59
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +299 -299
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +58 -58
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lines.php +127 -127
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Parser.php +53 -53
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +19 -19
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Value.php +88 -88
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +15 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +89 -89
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +80 -80
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +88 -88
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +85 -85
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +110 -110
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +48 -48
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +64 -64
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +91 -91
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +17 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +104 -104
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +88 -88
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +27 -27
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +107 -107
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +272 -272
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +51 -51
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +44 -44
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +81 -81
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/FileStore.php +72 -72
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +141 -141
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +17 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StringStore.php +37 -37
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Util/Regex.php +112 -112
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Util/Str.php +108 -108
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Validator.php +207 -207
- package/src/frontend/404.njk +2 -1
- package/src/frontend/components/global/footer.njk +13 -12
- package/src/frontend/components/global/header.njk +0 -4
- package/src/frontend/components/layouts/base.njk +47 -34
- package/src/frontend/components/welcome.njk +32 -668
- package/src/frontend/data/site.json +43 -43
- package/src/frontend/scss/modules/_buttons.scss +10 -4
- package/src/frontend/scss/modules/_footer.scss +5 -14
- package/src/frontend/scss/modules/_global.scss +1 -2
- package/src/frontend/scss/pages/404.scss +1 -1
- package/src/backend/_core/vendor/graham-campbell/result-type/.gitattributes +0 -9
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/CODE_OF_CONDUCT.md +0 -132
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/CONTRIBUTING.md +0 -31
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/FUNDING.yml +0 -2
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/SECURITY.md +0 -14
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/workflows/stale.yml +0 -11
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/workflows/tests.yml +0 -40
- package/src/backend/_core/vendor/graham-campbell/result-type/CHANGELOG.md +0 -53
- package/src/backend/_core/vendor/graham-campbell/result-type/README.md +0 -42
- package/src/backend/_core/vendor/graham-campbell/result-type/phpunit.xml.dist +0 -13
- package/src/backend/_core/vendor/graham-campbell/result-type/tests/ResultTest.php +0 -95
- package/src/backend/_core/vendor/phpoption/phpoption/.gitattributes +0 -13
- package/src/backend/_core/vendor/phpoption/phpoption/.github/CODE_OF_CONDUCT.md +0 -132
- package/src/backend/_core/vendor/phpoption/phpoption/.github/CONTRIBUTING.md +0 -30
- package/src/backend/_core/vendor/phpoption/phpoption/.github/FUNDING.yml +0 -2
- package/src/backend/_core/vendor/phpoption/phpoption/.github/SECURITY.md +0 -14
- package/src/backend/_core/vendor/phpoption/phpoption/.github/workflows/static.yml +0 -40
- package/src/backend/_core/vendor/phpoption/phpoption/.github/workflows/tests.yml +0 -40
- package/src/backend/_core/vendor/phpoption/phpoption/Makefile +0 -17
- package/src/backend/_core/vendor/phpoption/phpoption/README.md +0 -201
- package/src/backend/_core/vendor/phpoption/phpoption/phpstan-baseline.neon +0 -44
- package/src/backend/_core/vendor/phpoption/phpoption/phpstan.neon.dist +0 -7
- package/src/backend/_core/vendor/phpoption/phpoption/phpunit.xml.dist +0 -13
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +0 -72
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +0 -357
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +0 -153
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +0 -166
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +0 -194
- package/src/backend/_core/vendor/phpoption/phpoption/tests/bootstrap.php +0 -8
- package/src/backend/_core/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +0 -8
- package/src/backend/_core/vendor/vlucas/phpdotenv/.editorconfig +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/.gitattributes +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/CODE_OF_CONDUCT.md +0 -132
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/CONTRIBUTING.md +0 -30
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/FUNDING.yml +0 -2
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/SECURITY.md +0 -14
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/workflows/static.yml +0 -40
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/workflows/tests.yml +0 -70
- package/src/backend/_core/vendor/vlucas/phpdotenv/Makefile +0 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/README.md +0 -370
- package/src/backend/_core/vendor/vlucas/phpdotenv/UPGRADING.md +0 -196
- package/src/backend/_core/vendor/vlucas/phpdotenv/phpstan-baseline.neon +0 -157
- package/src/backend/_core/vendor/vlucas/phpdotenv/phpstan.neon.dist +0 -7
- package/src/backend/_core/vendor/vlucas/phpdotenv/phpunit.xml.dist +0 -13
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +0 -387
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +0 -86
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +0 -234
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +0 -40
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +0 -53
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +0 -98
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +0 -57
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +0 -75
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +0 -52
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +0 -75
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +0 -305
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +0 -141
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +0 -479
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +0 -5
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +0 -18
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +0 -33
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +0 -7
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +0 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +0 -2
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +0 -3
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +0 -14
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +0 -4
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +0 -11
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +0 -8
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +0 -2
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +0 -3
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +0 -15
- package/src/backend/config.php +0 -19
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# CONTRIBUTOR COVENANT CODE OF CONDUCT
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
-
nationality, personal appearance, race, caste, color, religion, or sexual identity
|
|
10
|
-
and orientation.
|
|
11
|
-
|
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
-
diverse, inclusive, and healthy community.
|
|
14
|
-
|
|
15
|
-
## Our Standards
|
|
16
|
-
|
|
17
|
-
Examples of behavior that contributes to a positive environment for our
|
|
18
|
-
community include:
|
|
19
|
-
|
|
20
|
-
* Demonstrating empathy and kindness toward other people
|
|
21
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
-
* Giving and gracefully accepting constructive feedback
|
|
23
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
-
and learning from the experience
|
|
25
|
-
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
-
overall community
|
|
27
|
-
|
|
28
|
-
Examples of unacceptable behavior include:
|
|
29
|
-
|
|
30
|
-
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
-
advances of any kind
|
|
32
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
-
* Public or private harassment
|
|
34
|
-
* Publishing others' private information, such as a physical or email
|
|
35
|
-
address, without their explicit permission
|
|
36
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
-
professional setting
|
|
38
|
-
|
|
39
|
-
## Enforcement Responsibilities
|
|
40
|
-
|
|
41
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
-
or harmful.
|
|
45
|
-
|
|
46
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
-
decisions when appropriate.
|
|
50
|
-
|
|
51
|
-
## Scope
|
|
52
|
-
|
|
53
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
-
an individual is officially representing the community in public spaces.
|
|
55
|
-
Examples of representing our community include using an official e-mail address,
|
|
56
|
-
posting via an official social media account, or acting as an appointed
|
|
57
|
-
representative at an online or offline event.
|
|
58
|
-
|
|
59
|
-
## Enforcement
|
|
60
|
-
|
|
61
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
-
reported to the community leaders responsible for enforcement at
|
|
63
|
-
hello@gjcampbell.co.uk.
|
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
-
|
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
-
reporter of any incident.
|
|
68
|
-
|
|
69
|
-
## Enforcement Guidelines
|
|
70
|
-
|
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
-
|
|
74
|
-
### 1. Correction
|
|
75
|
-
|
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
-
unprofessional or unwelcome in the community.
|
|
78
|
-
|
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
|
82
|
-
|
|
83
|
-
### 2. Warning
|
|
84
|
-
|
|
85
|
-
**Community Impact**: A violation through a single incident or series
|
|
86
|
-
of actions.
|
|
87
|
-
|
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
-
like social media. Violating these terms may lead to a temporary or
|
|
93
|
-
permanent ban.
|
|
94
|
-
|
|
95
|
-
### 3. Temporary Ban
|
|
96
|
-
|
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
|
98
|
-
sustained inappropriate behavior.
|
|
99
|
-
|
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
-
communication with the community for a specified period of time. No public or
|
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
-
Violating these terms may lead to a permanent ban.
|
|
105
|
-
|
|
106
|
-
### 4. Permanent Ban
|
|
107
|
-
|
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
-
|
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
-
the community.
|
|
114
|
-
|
|
115
|
-
## Attribution
|
|
116
|
-
|
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
-
version 2.1, available at
|
|
119
|
-
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
-
|
|
121
|
-
Community Impact Guidelines were inspired by
|
|
122
|
-
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
-
|
|
124
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
|
126
|
-
at [https://www.contributor-covenant.org/translations][translations].
|
|
127
|
-
|
|
128
|
-
[homepage]: https://www.contributor-covenant.org
|
|
129
|
-
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
-
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
-
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
-
[translations]: https://www.contributor-covenant.org/translations
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# CONTRIBUTION GUIDELINES
|
|
2
|
-
|
|
3
|
-
Contributions are **welcome** and will be fully **credited**.
|
|
4
|
-
|
|
5
|
-
We accept contributions via pull requests on GitHub. Please review these guidelines before continuing.
|
|
6
|
-
|
|
7
|
-
## Guidelines
|
|
8
|
-
|
|
9
|
-
* Please follow the [PSR-12 Coding Style Guide](https://www.php-fig.org/psr/psr-12/).
|
|
10
|
-
* Ensure that the current tests pass, and if you've added something new, add the tests where relevant.
|
|
11
|
-
* Send a coherent commit history, making sure each individual commit in your pull request is meaningful.
|
|
12
|
-
* You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts.
|
|
13
|
-
* If you are changing or adding to the behaviour or public api, you may need to update the docs.
|
|
14
|
-
* Please remember that we follow [SemVer](https://semver.org/).
|
|
15
|
-
|
|
16
|
-
## Running Tests
|
|
17
|
-
|
|
18
|
-
First, install the dependencies using [Composer](https://getcomposer.org/):
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
$ make install
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Then run [PHPUnit](https://phpunit.de/) and the static analyzers:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
$ make test
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
These will also be automatically run by [GitHub Actions](https://github.com/features/actions) against pull requests.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# SECURITY POLICY
|
|
2
|
-
|
|
3
|
-
## Supported Versions
|
|
4
|
-
|
|
5
|
-
After each new major release, the previous release will be supported for no
|
|
6
|
-
less than 2 years, unless explicitly stated otherwise. This may mean that there
|
|
7
|
-
are multiple supported versions at any given time.
|
|
8
|
-
|
|
9
|
-
## Reporting a Vulnerability
|
|
10
|
-
|
|
11
|
-
If you discover a security vulnerability within this package, please send an
|
|
12
|
-
email to security@tidelift.com. All security vulnerabilities will be promptly
|
|
13
|
-
addressed. Please do not disclose security-related issues publicly until a fix
|
|
14
|
-
has been announced.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
name: Static Analysis
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
pull_request:
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
phpstan:
|
|
9
|
-
name: PHPStan
|
|
10
|
-
runs-on: ubuntu-24.04
|
|
11
|
-
|
|
12
|
-
steps:
|
|
13
|
-
- name: Checkout code
|
|
14
|
-
uses: actions/checkout@v6
|
|
15
|
-
|
|
16
|
-
- name: Setup PHP
|
|
17
|
-
uses: shivammathur/setup-php@v2
|
|
18
|
-
with:
|
|
19
|
-
php-version: '8.5'
|
|
20
|
-
tools: composer:v2
|
|
21
|
-
coverage: none
|
|
22
|
-
env:
|
|
23
|
-
update: true
|
|
24
|
-
|
|
25
|
-
- name: Install Dependencies
|
|
26
|
-
uses: nick-invision/retry@v3
|
|
27
|
-
with:
|
|
28
|
-
timeout_minutes: 5
|
|
29
|
-
max_attempts: 5
|
|
30
|
-
command: composer update --no-interaction --no-progress
|
|
31
|
-
|
|
32
|
-
- name: Install PHPStan
|
|
33
|
-
uses: nick-invision/retry@v3
|
|
34
|
-
with:
|
|
35
|
-
timeout_minutes: 5
|
|
36
|
-
max_attempts: 5
|
|
37
|
-
command: composer bin phpstan update --no-interaction --no-progress
|
|
38
|
-
|
|
39
|
-
- name: Execute PHPStan
|
|
40
|
-
run: vendor/bin/phpstan analyze --no-progress
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
name: Tests
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
pull_request:
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
tests:
|
|
9
|
-
name: PHP ${{ matrix.php }}
|
|
10
|
-
runs-on: ubuntu-24.04
|
|
11
|
-
|
|
12
|
-
strategy:
|
|
13
|
-
matrix:
|
|
14
|
-
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
|
|
15
|
-
|
|
16
|
-
steps:
|
|
17
|
-
- name: Checkout Code
|
|
18
|
-
uses: actions/checkout@v6
|
|
19
|
-
|
|
20
|
-
- name: Setup PHP
|
|
21
|
-
uses: shivammathur/setup-php@v2
|
|
22
|
-
with:
|
|
23
|
-
php-version: ${{ matrix.php }}
|
|
24
|
-
tools: composer:v2
|
|
25
|
-
coverage: none
|
|
26
|
-
env:
|
|
27
|
-
update: true
|
|
28
|
-
|
|
29
|
-
- name: Setup Problem Matchers
|
|
30
|
-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
|
31
|
-
|
|
32
|
-
- name: Install PHP Dependencies
|
|
33
|
-
uses: nick-invision/retry@v3
|
|
34
|
-
with:
|
|
35
|
-
timeout_minutes: 5
|
|
36
|
-
max_attempts: 5
|
|
37
|
-
command: composer update --no-interaction --no-progress
|
|
38
|
-
|
|
39
|
-
- name: Execute PHPUnit
|
|
40
|
-
run: vendor/bin/phpunit
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
install:
|
|
2
|
-
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.5-base update
|
|
3
|
-
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.5-base bin all update
|
|
4
|
-
|
|
5
|
-
phpunit:
|
|
6
|
-
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:8.5-cli
|
|
7
|
-
|
|
8
|
-
phpstan-analyze:
|
|
9
|
-
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.5-cli analyze
|
|
10
|
-
|
|
11
|
-
phpstan-baseline:
|
|
12
|
-
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.5-cli analyze --generate-baseline
|
|
13
|
-
|
|
14
|
-
test: phpunit phpstan-analyze
|
|
15
|
-
|
|
16
|
-
clean:
|
|
17
|
-
@rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
# PHP Option Type
|
|
2
|
-
|
|
3
|
-
This package implements the Option type for PHP!
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg?style=flat-square" alt="Software License"></img></a>
|
|
9
|
-
<a href="https://packagist.org/packages/phpoption/phpoption"><img src="https://img.shields.io/packagist/dt/phpoption/phpoption.svg?style=flat-square" alt="Total Downloads"></img></a>
|
|
10
|
-
<a href="https://github.com/schmittjoh/php-option/releases"><img src="https://img.shields.io/github/release/schmittjoh/php-option.svg?style=flat-square" alt="Latest Version"></img></a>
|
|
11
|
-
</p>
|
|
12
|
-
|
|
13
|
-
<div align="center">
|
|
14
|
-
|
|
15
|
-
**Special thanks to [our sponsors](https://github.com/sponsors/GrahamCampbell)**
|
|
16
|
-
|
|
17
|
-
<hr>
|
|
18
|
-
</div>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Motivation
|
|
22
|
-
|
|
23
|
-
The Option type is intended for cases where you sometimes might return a value
|
|
24
|
-
(typically an object), and sometimes you might return a base value (typically
|
|
25
|
-
null) depending on arguments, or other runtime factors.
|
|
26
|
-
|
|
27
|
-
Often times, you forget to handle the case where a base value should be
|
|
28
|
-
returned. Not intentionally of course, but maybe you did not account for all
|
|
29
|
-
possible states of the system; or maybe you indeed covered all cases, then time
|
|
30
|
-
goes on, code is refactored, some of these your checks might become invalid, or
|
|
31
|
-
incomplete. Suddenly, without noticing, the base value case is not handled
|
|
32
|
-
anymore. As a result, you might sometimes get fatal PHP errors telling you that
|
|
33
|
-
you called a method on a non-object; users might see blank pages, or worse.
|
|
34
|
-
|
|
35
|
-
On one hand, the Option type forces a developer to consciously think about both
|
|
36
|
-
cases (returning a value, or returning a base value). That in itself will
|
|
37
|
-
already make your code more robust. On the other hand, the Option type also
|
|
38
|
-
allows the API developer to provide more concise API methods, and empowers the
|
|
39
|
-
API user in how he consumes these methods.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## Installation
|
|
43
|
-
|
|
44
|
-
Installation is super-easy via [Composer](https://getcomposer.org/):
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
$ composer require phpoption/phpoption
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
or add it by hand to your `composer.json` file.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
## Usage
|
|
54
|
-
|
|
55
|
-
### Using the Option Type in your API
|
|
56
|
-
|
|
57
|
-
```php
|
|
58
|
-
class MyRepository
|
|
59
|
-
{
|
|
60
|
-
public function findSomeEntity($criteria): \PhpOption\Option
|
|
61
|
-
{
|
|
62
|
-
if (null !== $entity = $this->em->find(...)) {
|
|
63
|
-
return new \PhpOption\Some($entity);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// We use a singleton, for the None case.
|
|
67
|
-
return \PhpOption\None::create();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
If you are consuming an existing library, you can also use a shorter version
|
|
73
|
-
which by default treats `null` as `None`, and everything else as `Some` case:
|
|
74
|
-
|
|
75
|
-
```php
|
|
76
|
-
class MyRepository
|
|
77
|
-
{
|
|
78
|
-
public function findSomeEntity($criteria): \PhpOption\Option
|
|
79
|
-
{
|
|
80
|
-
return \PhpOption\Option::fromValue($this->em->find(...));
|
|
81
|
-
|
|
82
|
-
// or, if you want to change the none value to false for example:
|
|
83
|
-
return \PhpOption\Option::fromValue($this->em->find(...), false);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Case 1: You always Require an Entity in Calling Code
|
|
89
|
-
|
|
90
|
-
```php
|
|
91
|
-
$entity = $repo->findSomeEntity(...)->get(); // returns entity, or throws exception
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Case 2: Fallback to Default Value If Not Available
|
|
95
|
-
|
|
96
|
-
```php
|
|
97
|
-
$entity = $repo->findSomeEntity(...)->getOrElse(new Entity());
|
|
98
|
-
|
|
99
|
-
// Or, if you want to lazily create the entity.
|
|
100
|
-
$entity = $repo->findSomeEntity(...)->getOrCall(function() {
|
|
101
|
-
return new Entity();
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## More Examples
|
|
106
|
-
|
|
107
|
-
### No More Boiler Plate Code
|
|
108
|
-
|
|
109
|
-
```php
|
|
110
|
-
// Before
|
|
111
|
-
$entity = $this->findSomeEntity();
|
|
112
|
-
if (null === $entity) {
|
|
113
|
-
throw new NotFoundException();
|
|
114
|
-
}
|
|
115
|
-
echo $entity->name;
|
|
116
|
-
|
|
117
|
-
// After
|
|
118
|
-
echo $this->findSomeEntity()->get()->name;
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### No More Control Flow Exceptions
|
|
122
|
-
|
|
123
|
-
```php
|
|
124
|
-
// Before
|
|
125
|
-
try {
|
|
126
|
-
$entity = $this->findSomeEntity();
|
|
127
|
-
} catch (NotFoundException $ex) {
|
|
128
|
-
$entity = new Entity();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// After
|
|
132
|
-
$entity = $this->findSomeEntity()->getOrElse(new Entity());
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### More Concise Null Handling
|
|
136
|
-
|
|
137
|
-
```php
|
|
138
|
-
// Before
|
|
139
|
-
$entity = $this->findSomeEntity();
|
|
140
|
-
if (null === $entity) {
|
|
141
|
-
return new Entity();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return $entity;
|
|
145
|
-
|
|
146
|
-
// After
|
|
147
|
-
return $this->findSomeEntity()->getOrElse(new Entity());
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Trying Multiple Alternative Options
|
|
151
|
-
|
|
152
|
-
If you'd like to try multiple alternatives, the `orElse` method allows you to
|
|
153
|
-
do this very elegantly:
|
|
154
|
-
|
|
155
|
-
```php
|
|
156
|
-
return $this->findSomeEntity()
|
|
157
|
-
->orElse($this->findSomeOtherEntity())
|
|
158
|
-
->orElse($this->createEntity());
|
|
159
|
-
```
|
|
160
|
-
The first option which is non-empty will be returned. This is especially useful
|
|
161
|
-
with lazy-evaluated options, see below.
|
|
162
|
-
|
|
163
|
-
### Lazy-Evaluated Options
|
|
164
|
-
|
|
165
|
-
The above example has the flaw that we would need to evaluate all options when
|
|
166
|
-
the method is called which creates unnecessary overhead if the first option is
|
|
167
|
-
already non-empty.
|
|
168
|
-
|
|
169
|
-
Fortunately, we can easily solve this by using the `LazyOption` class:
|
|
170
|
-
|
|
171
|
-
```php
|
|
172
|
-
return $this->findSomeEntity()
|
|
173
|
-
->orElse(new LazyOption(array($this, 'findSomeOtherEntity')))
|
|
174
|
-
->orElse(new LazyOption(array($this, 'createEntity')));
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
This way, only the options that are necessary will actually be evaluated.
|
|
178
|
-
|
|
179
|
-
## Performance Considerations
|
|
180
|
-
|
|
181
|
-
Of course, performance is important. Attached is a performance benchmark which
|
|
182
|
-
you can run on a machine of your choosing. The overhead incurred by the Option
|
|
183
|
-
type comes down to the time that it takes to create one object, our wrapper,
|
|
184
|
-
and one additional method call to retrieve the value from the wrapper. Unless
|
|
185
|
-
you plan to call a method thousands of times during a request, there is no
|
|
186
|
-
reason to stick to the `object|null` return value; better give your code some
|
|
187
|
-
options!
|
|
188
|
-
|
|
189
|
-
## Security
|
|
190
|
-
|
|
191
|
-
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. You may view our full security policy [here](https://github.com/schmittjoh/php-option/security/policy).
|
|
192
|
-
|
|
193
|
-
## License
|
|
194
|
-
|
|
195
|
-
PHP Option Type is licensed under [Apache License 2.0](LICENSE).
|
|
196
|
-
|
|
197
|
-
## For Enterprise
|
|
198
|
-
|
|
199
|
-
Available as part of the Tidelift Subscription
|
|
200
|
-
|
|
201
|
-
The maintainers of `phpoption/phpoption` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-phpoption-phpoption?utm_source=packagist-phpoption-phpoption&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
parameters:
|
|
2
|
-
ignoreErrors:
|
|
3
|
-
-
|
|
4
|
-
message: '#^Call to function is_callable\(\) with callable\(mixed \.\.\.\)\: PhpOption\\Option\<T\> will always evaluate to true\.$#'
|
|
5
|
-
identifier: function.alreadyNarrowedType
|
|
6
|
-
count: 1
|
|
7
|
-
path: src/PhpOption/LazyOption.php
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
message: '#^Method PhpOption\\Option\:\:ensure\(\) should return PhpOption\\Option\<S\> but returns PhpOption\\LazyOption\<mixed\>\.$#'
|
|
11
|
-
identifier: return.type
|
|
12
|
-
count: 1
|
|
13
|
-
path: src/PhpOption/Option.php
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
message: '#^Method PhpOption\\Option\:\:fromReturn\(\) has parameter \$arguments with no value type specified in iterable type array\.$#'
|
|
17
|
-
identifier: missingType.iterableValue
|
|
18
|
-
count: 1
|
|
19
|
-
path: src/PhpOption/Option.php
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
message: '#^Method PhpOption\\Option\:\:fromReturn\(\) should return PhpOption\\LazyOption\<S\> but returns PhpOption\\LazyOption\<mixed\>\.$#'
|
|
23
|
-
identifier: return.type
|
|
24
|
-
count: 1
|
|
25
|
-
path: src/PhpOption/Option.php
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(mixed\)\: mixed\)\|null, Closure\(PhpOption\\Option\)\: T given\.$#'
|
|
29
|
-
identifier: argument.type
|
|
30
|
-
count: 1
|
|
31
|
-
path: src/PhpOption/Option.php
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
message: '#^Parameter \#2 \$callback of function array_reduce expects callable\(bool\|TReturn, mixed\)\: \(bool\|TReturn\), Closure\(mixed, PhpOption\\Option\)\: \(bool\|TReturn\) given\.$#'
|
|
35
|
-
identifier: argument.type
|
|
36
|
-
count: 1
|
|
37
|
-
path: src/PhpOption/Option.php
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
message: '#^Template type S of method PhpOption\\Option\:\:lift\(\) is not referenced in a parameter\.$#'
|
|
41
|
-
identifier: method.templateTypeNotInParameter
|
|
42
|
-
count: 1
|
|
43
|
-
path: src/PhpOption/Option.php
|
|
44
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="tests/bootstrap.php" colors="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd">
|
|
3
|
-
<testsuites>
|
|
4
|
-
<testsuite name="PhpOption Type Test Suite">
|
|
5
|
-
<directory>./tests/PhpOption/</directory>
|
|
6
|
-
</testsuite>
|
|
7
|
-
</testsuites>
|
|
8
|
-
<groups>
|
|
9
|
-
<exclude>
|
|
10
|
-
<group>performance</group>
|
|
11
|
-
</exclude>
|
|
12
|
-
</groups>
|
|
13
|
-
</phpunit>
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace PhpOption\Tests;
|
|
4
|
-
|
|
5
|
-
use PhpOption\None;
|
|
6
|
-
use PhpOption\Option;
|
|
7
|
-
use PhpOption\Some;
|
|
8
|
-
use PHPUnit\Framework\TestCase;
|
|
9
|
-
|
|
10
|
-
class EnsureTest extends TestCase
|
|
11
|
-
{
|
|
12
|
-
private static function ensure($value, $noneValue = null): Option
|
|
13
|
-
{
|
|
14
|
-
$option = Option::ensure($value, $noneValue);
|
|
15
|
-
self::assertInstanceOf(Option::class, $option);
|
|
16
|
-
|
|
17
|
-
return $option;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public function testMixedValue(): void
|
|
21
|
-
{
|
|
22
|
-
$option = self::ensure(1);
|
|
23
|
-
self::assertTrue($option->isDefined());
|
|
24
|
-
self::assertSame(1, $option->get());
|
|
25
|
-
self::assertFalse(self::ensure(null)->isDefined());
|
|
26
|
-
self::assertFalse(self::ensure(1, 1)->isDefined());
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public function testReturnValue(): void
|
|
30
|
-
{
|
|
31
|
-
$option = self::ensure(function () {
|
|
32
|
-
return 1;
|
|
33
|
-
});
|
|
34
|
-
self::assertTrue($option->isDefined());
|
|
35
|
-
self::assertSame(1, $option->get());
|
|
36
|
-
self::assertFalse(self::ensure(function () {
|
|
37
|
-
})->isDefined());
|
|
38
|
-
self::assertFalse(self::ensure(function () {
|
|
39
|
-
return 1;
|
|
40
|
-
}, 1)->isDefined());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public function testOptionReturnsAsSameInstance(): void
|
|
44
|
-
{
|
|
45
|
-
$option = self::ensure(1);
|
|
46
|
-
self::assertSame($option, self::ensure($option));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public function testOptionReturnedFromClosure(): void
|
|
50
|
-
{
|
|
51
|
-
$option = self::ensure(function () {
|
|
52
|
-
return Some::create(1);
|
|
53
|
-
});
|
|
54
|
-
self::assertTrue($option->isDefined());
|
|
55
|
-
self::assertSame(1, $option->get());
|
|
56
|
-
|
|
57
|
-
$option = self::ensure(function () {
|
|
58
|
-
return None::create();
|
|
59
|
-
});
|
|
60
|
-
self::assertFalse($option->isDefined());
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public function testClosureReturnedFromClosure(): void
|
|
64
|
-
{
|
|
65
|
-
$option = self::ensure(function () {
|
|
66
|
-
return function () {
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
self::assertTrue($option->isDefined());
|
|
70
|
-
self::assertInstanceOf('Closure', $option->get());
|
|
71
|
-
}
|
|
72
|
-
}
|