committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
629 changed files with 64416 additions and 372 deletions
-
2.travis.yml
-
2composer.json
-
67lam-packaging/debian/copyright
-
1lam-packaging/docker/Dockerfile
-
5lam/HISTORY
-
10lam/composer.json
-
1259lam/composer.lock
-
1lam/config/.gitignore
-
67lam/copyright
-
47lam/docs/manual-sources/appendix-security.xml
-
59lam/docs/manual-sources/chapter-configuration.xml
-
2lam/docs/manual-sources/chapter-installation.xml
-
47lam/docs/manual-sources/chapter-selfService.xml
-
17lam/docs/manual-sources/chapter-tools.xml
-
BINlam/docs/manual-sources/images/configGeneral8.png
-
BINlam/docs/manual-sources/images/tool_webauthn1.png
-
BINlam/docs/manual-sources/images/webauthn.png
-
2lam/docs/manual-sources/overview.xml
-
BINlam/graphics/webauthn.png
-
31lam/graphics/webauthn.svg
-
4lam/help/help.inc
-
159lam/lib/2factor.inc
-
7lam/lib/3rdParty/composer/autoload.php
-
11lam/lib/3rdParty/composer/beberlei/assert/LICENSE
-
63lam/lib/3rdParty/composer/beberlei/assert/composer.json
-
96lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/Assert.php
-
2825lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/Assertion.php
-
254lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/AssertionChain.php
-
35lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/AssertionFailedException.php
-
76lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/InvalidArgumentException.php
-
230lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/LazyAssertion.php
-
55lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/LazyAssertionException.php
-
80lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/functions.php
-
10lam/lib/3rdParty/composer/beberlei/assert/phpstan-code.neon
-
10lam/lib/3rdParty/composer/beberlei/assert/phpstan-tests.neon
-
445lam/lib/3rdParty/composer/composer/ClassLoader.php
-
56lam/lib/3rdParty/composer/composer/LICENSE
-
9lam/lib/3rdParty/composer/composer/autoload_classmap.php
-
14lam/lib/3rdParty/composer/composer/autoload_files.php
-
9lam/lib/3rdParty/composer/composer/autoload_namespaces.php
-
28lam/lib/3rdParty/composer/composer/autoload_psr4.php
-
70lam/lib/3rdParty/composer/composer/autoload_real.php
-
157lam/lib/3rdParty/composer/composer/autoload_static.php
-
1285lam/lib/3rdParty/composer/composer/installed.json
-
38lam/lib/3rdParty/composer/fgrosse/phpasn1/CHANGELOG.md
-
19lam/lib/3rdParty/composer/fgrosse/phpasn1/LICENSE
-
167lam/lib/3rdParty/composer/fgrosse/phpasn1/README.md
-
47lam/lib/3rdParty/composer/fgrosse/phpasn1/composer.json
-
355lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/ASNObject.php
-
136lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/AbstractString.php
-
78lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/AbstractTime.php
-
63lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Base128.php
-
35lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Composite/AttributeTypeAndValue.php
-
37lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Composite/RDNString.php
-
50lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Composite/RelativeDistinguishedName.php
-
191lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Construct.php
-
15lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Exception/NotImplementedException.php
-
29lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Exception/ParserException.php
-
131lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/ExplicitlyTaggedObject.php
-
339lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Identifier.php
-
198lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/OID.php
-
32lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Parsable.php
-
70lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/TemplateParser.php
-
41lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/BMPString.php
-
88lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/BitString.php
-
75lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/Boolean.php
-
28lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/CharacterString.php
-
21lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/Enumerated.php
-
34lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/GeneralString.php
-
134lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/GeneralizedTime.php
-
34lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/GraphicString.php
-
35lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/IA5String.php
-
130lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/Integer.php
-
54lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/NullObject.php
-
38lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/NumericString.php
-
26lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/ObjectDescriptor.php
-
138lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/ObjectIdentifier.php
-
91lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/OctetString.php
-
53lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/PrintableString.php
-
57lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/RelativeObjectIdentifier.php
-
23lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/Sequence.php
-
21lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/Set.php
-
36lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/T61String.php
-
77lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/UTCTime.php
-
34lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/UTF8String.php
-
36lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/UniversalString.php
-
34lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/Universal/VisibleString.php
-
59lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/UnknownConstructedObject.php
-
59lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/ASN1/UnknownObject.php
-
197lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/Utility/BigInteger.php
-
133lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/Utility/BigIntegerBcmath.php
-
133lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/Utility/BigIntegerGmp.php
-
22lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/AlgorithmIdentifier.php
-
68lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/CSR/Attributes.php
-
137lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/CSR/CSR.php
-
100lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/CertificateExtensions.php
-
108lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/CertificateSubject.php
-
35lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/PrivateKey.php
-
35lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/PublicKey.php
-
28lam/lib/3rdParty/composer/fgrosse/phpasn1/lib/X509/SAN/DNSName.php
@ -0,0 +1,10 @@ |
|||
{ |
|||
"config": { |
|||
"vendor-dir": "lib/3rdParty/composer" |
|||
}, |
|||
"require" : { |
|||
"web-auth/webauthn-lib" : "2.1.7", |
|||
"symfony/http-foundation" : "5.0.0", |
|||
"symfony/psr-http-message-bridge" : "1.3.0" |
|||
} |
|||
} |
1259
lam/composer.lock
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
After Width: 1365 | Height: 361 | Size: 35 KiB |
After Width: 1579 | Height: 492 | Size: 62 KiB |
After Width: 16 | Height: 16 | Size: 810 B |
After Width: 16 | Height: 16 | Size: 810 B |
31
lam/graphics/webauthn.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,7 @@ |
|||
<?php |
|||
|
|||
// autoload.php @generated by Composer
|
|||
|
|||
require_once __DIR__ . '/composer/autoload_real.php'; |
|||
|
|||
return ComposerAutoloaderInited73ceb9c1bdec18b7c6d09764d1bce5::getLoader(); |
@ -0,0 +1,11 @@ |
|||
Copyright (c) 2011-2013, Benjamin Eberlei |
|||
All rights reserved. |
|||
|
|||
Redistribution and use in source and binary forms, with or without |
|||
modification, are permitted provided that the following conditions are met: |
|||
|
|||
- Redistributions of source code must retain the above copyright notice, this |
|||
list of conditions and the following disclaimer. |
|||
- Redistributions in binary form must reproduce the above copyright notice, |
|||
this list of conditions and the following disclaimer in the documentation |
|||
and/or other materials provided with the distribution. |
@ -0,0 +1,63 @@ |
|||
{ |
|||
"name": "beberlei/assert", |
|||
"description": "Thin assertion library for input validation in business models.", |
|||
"authors": [ |
|||
{ |
|||
"name": "Benjamin Eberlei", |
|||
"email": "kontakt@beberlei.de", |
|||
"role": "Lead Developer" |
|||
}, |
|||
{ |
|||
"name": "Richard Quadling", |
|||
"email": "rquadling@gmail.com", |
|||
"role": "Collaborator" |
|||
} |
|||
], |
|||
"license": "BSD-2-Clause", |
|||
"keywords": [ |
|||
"assert", |
|||
"assertion", |
|||
"validation" |
|||
], |
|||
"autoload": { |
|||
"psr-4": { |
|||
"Assert\\": "lib/Assert" |
|||
}, |
|||
"files": [ |
|||
"lib/Assert/functions.php" |
|||
] |
|||
}, |
|||
"autoload-dev": { |
|||
"psr-4": { |
|||
"Assert\\Tests\\": "tests/Assert/Tests" |
|||
}, |
|||
"files": [ |
|||
"tests/Assert/Tests/Fixtures/functions.php" |
|||
] |
|||
}, |
|||
"config": { |
|||
"sort-packages": true |
|||
}, |
|||
"require": { |
|||
"php": "^7", |
|||
"ext-simplexml": "*", |
|||
"ext-mbstring": "*", |
|||
"ext-ctype": "*", |
|||
"ext-json": "*" |
|||
}, |
|||
"require-dev": { |
|||
"friendsofphp/php-cs-fixer": "*", |
|||
"phpstan/phpstan-shim": "*", |
|||
"phpunit/phpunit": ">=6.0.0 <8" |
|||
}, |
|||
"scripts": { |
|||
"assert:generate-docs": "php bin/generate_method_docs.php", |
|||
"assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run", |
|||
"assert:cs-fix": "php-cs-fixer fix . -vvv || true", |
|||
"assert:sa-code": "vendor/bin/phpstan analyse --configuration=phpstan-code.neon --no-progress --ansi -l 7 bin lib", |
|||
"assert:sa-tests": "vendor/bin/phpstan analyse --configuration=phpstan-tests.neon --no-progress --ansi -l 7 tests" |
|||
}, |
|||
"suggest": { |
|||
"ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles" |
|||
} |
|||
} |
@ -0,0 +1,96 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* Assert |
|||
* |
|||
* LICENSE |
|||
* |
|||
* This source file is subject to the MIT license that is bundled |
|||
* with this package in the file LICENSE.txt. |
|||
* If you did not receive a copy of the license and are unable to |
|||
* obtain it through the world-wide-web, please send an email |
|||
* to kontakt@beberlei.de so I can send you a copy immediately. |
|||
*/ |
|||
|
|||
namespace Assert; |
|||
|
|||
/** |
|||
* AssertionChain factory. |
|||
*/ |
|||
abstract class Assert |
|||
{ |
|||
/** @var string */ |
|||
protected static $lazyAssertionExceptionClass = LazyAssertionException::class; |
|||
|
|||
/** @var string */ |
|||
protected static $assertionClass = Assertion::class; |
|||
|
|||
/** |
|||
* Start validation on a value, returns {@link AssertionChain}. |
|||
* |
|||
* The invocation of this method starts an assertion chain |
|||
* that is happening on the passed value. |
|||
* |
|||
* @param mixed $value |
|||
* @param string|callable|null $defaultMessage |
|||
* @param string|null $defaultPropertyPath |
|||
* |
|||
* @return AssertionChain |
|||
* |
|||
* @example |
|||
* |
|||
* Assert::that($value)->notEmpty()->integer(); |
|||
* Assert::that($value)->nullOr()->string()->startsWith("Foo"); |
|||
* |
|||
* The assertion chain can be stateful, that means be careful when you reuse |
|||
* it. You should never pass around the chain. |
|||
*/ |
|||
public static function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain |
|||
{ |
|||
$assertionChain = new AssertionChain($value, $defaultMessage, $defaultPropertyPath); |
|||
|
|||
return $assertionChain->setAssertionClassName(static::$assertionClass); |
|||
} |
|||
|
|||
/** |
|||
* Start validation on a set of values, returns {@link AssertionChain}. |
|||
* |
|||
* @param mixed $values |
|||
* @param string|callable|null $defaultMessage |
|||
* @param string|null $defaultPropertyPath |
|||
* |
|||
* @return AssertionChain |
|||
*/ |
|||
public static function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain |
|||
{ |
|||
return static::that($values, $defaultMessage, $defaultPropertyPath)->all(); |
|||
} |
|||
|
|||
/** |
|||
* Start validation and allow NULL, returns {@link AssertionChain}. |
|||
* |
|||
* @param mixed $value |
|||
* @param string|callable|null $defaultMessage |
|||
* @param string|null $defaultPropertyPath |
|||
* |
|||
* @return AssertionChain |
|||
*/ |
|||
public static function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain |
|||
{ |
|||
return static::that($value, $defaultMessage, $defaultPropertyPath)->nullOr(); |
|||
} |
|||
|
|||
/** |
|||
* Create a lazy assertion object. |
|||
* |
|||
* @return LazyAssertion |
|||
*/ |
|||
public static function lazy(): LazyAssertion |
|||
{ |
|||
$lazyAssertion = new LazyAssertion(); |
|||
|
|||
return $lazyAssertion |
|||
->setAssertClass(\get_called_class()) |
|||
->setExceptionClass(static::$lazyAssertionExceptionClass); |
|||
} |
|||
} |
2825
lam/lib/3rdParty/composer/beberlei/assert/lib/Assert/Assertion.php
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,254 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* Assert |
|||
* |
|||
* LICENSE |
|||
* |
|||
* This source file is subject to the MIT license that is bundled |
|||
* with this package in the file LICENSE.txt. |
|||
* If you did not receive a copy of the license and are unable to |
|||
* obtain it through the world-wide-web, please send an email |
|||
* to kontakt@beberlei.de so I can send you a copy immediately. |
|||
*/ |
|||
|
|||
namespace Assert; |
|||
|
|||
use LogicException; |
|||
use ReflectionClass; |
|||
|
|||
/** |
|||
* Chaining builder for assertions. |
|||
* |
|||
* @author Benjamin Eberlei <kontakt@beberlei.de> |
|||
* |
|||
* @method AssertionChain alnum(string|callable $message = null, string $propertyPath = null) Assert that value is alphanumeric. |
|||
* @method AssertionChain base64(string|callable $message = null, string $propertyPath = null) Assert that a constant is defined. |
|||
* @method AssertionChain between(mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater or equal than a lower limit, and less than or equal to an upper limit. |
|||
* @method AssertionChain betweenExclusive(mixed $lowerLimit, mixed $upperLimit, string|callable $message = null, string $propertyPath = null) Assert that a value is greater than a lower limit, and less than an upper limit. |
|||
* @method AssertionChain betweenLength(int $minLength, int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string length is between min and max lengths. |
|||
* @method AssertionChain boolean(string|callable $message = null, string $propertyPath = null) Assert that value is php boolean. |
|||
* @method AssertionChain choice(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices. |
|||
* @method AssertionChain choicesNotEmpty(array $choices, string|callable $message = null, string $propertyPath = null) Determines if the values array has every choice as key and that this choice has content. |
|||
* @method AssertionChain classExists(string|callable $message = null, string $propertyPath = null) Assert that the class exists. |
|||
* @method AssertionChain contains(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string contains a sequence of chars. |
|||
* @method AssertionChain count(int $count, string|callable $message = null, string $propertyPath = null) Assert that the count of countable is equal to count. |
|||
* @method AssertionChain date(string $format, string|callable $message = null, string $propertyPath = null) Assert that date is valid and corresponds to the given format. |
|||
* @method AssertionChain defined(string|callable $message = null, string $propertyPath = null) Assert that a constant is defined. |
|||
* @method AssertionChain digit(string|callable $message = null, string $propertyPath = null) Validates if an integer or integerish is a digit. |
|||
* @method AssertionChain directory(string|callable $message = null, string $propertyPath = null) Assert that a directory exists. |
|||
* @method AssertionChain e164(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid E164 Phone Number. |
|||
* @method AssertionChain email(string|callable $message = null, string $propertyPath = null) Assert that value is an email address (using input_filter/FILTER_VALIDATE_EMAIL). |
|||
* @method AssertionChain endsWith(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string ends with a sequence of chars. |
|||
* @method AssertionChain eq(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are equal (using ==). |
|||
* @method AssertionChain eqArraySubset(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that the array contains the subset. |
|||
* @method AssertionChain extensionLoaded(string|callable $message = null, string $propertyPath = null) Assert that extension is loaded. |
|||
* @method AssertionChain extensionVersion(string $operator, mixed $version, string|callable $message = null, string $propertyPath = null) Assert that extension is loaded and a specific version is installed. |
|||
* @method AssertionChain false(string|callable $message = null, string $propertyPath = null) Assert that the value is boolean False. |
|||
* @method AssertionChain file(string|callable $message = null, string $propertyPath = null) Assert that a file exists. |
|||
* @method AssertionChain float(string|callable $message = null, string $propertyPath = null) Assert that value is a php float. |
|||
* @method AssertionChain greaterOrEqualThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater or equal than given limit. |
|||
* @method AssertionChain greaterThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is greater than given limit. |
|||
* @method AssertionChain implementsInterface(string $interfaceName, string|callable $message = null, string $propertyPath = null) Assert that the class implements the interface. |
|||
* @method AssertionChain inArray(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is in array of choices. This is an alias of Assertion::choice(). |
|||
* @method AssertionChain integer(string|callable $message = null, string $propertyPath = null) Assert that value is a php integer. |
|||
* @method AssertionChain integerish(string|callable $message = null, string $propertyPath = null) Assert that value is a php integer'ish. |
|||
* @method AssertionChain interfaceExists(string|callable $message = null, string $propertyPath = null) Assert that the interface exists. |
|||
* @method AssertionChain ip(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 or IPv6 address. |
|||
* @method AssertionChain ipv4(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv4 address. |
|||
* @method AssertionChain ipv6(int $flag = null, string|callable $message = null, string $propertyPath = null) Assert that value is an IPv6 address. |
|||
* @method AssertionChain isArray(string|callable $message = null, string $propertyPath = null) Assert that value is an array. |
|||
* @method AssertionChain isArrayAccessible(string|callable $message = null, string $propertyPath = null) Assert that value is an array or an array-accessible object. |
|||
* @method AssertionChain isCallable(string|callable $message = null, string $propertyPath = null) Determines that the provided value is callable. |
|||
* @method AssertionChain isCountable(string|callable $message = null, string $propertyPath = null) Assert that value is countable. |
|||
* @method AssertionChain isInstanceOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is instance of given class-name. |
|||
* @method AssertionChain isJsonString(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid json string. |
|||
* @method AssertionChain isObject(string|callable $message = null, string $propertyPath = null) Determines that the provided value is an object. |
|||
* @method AssertionChain isResource(string|callable $message = null, string $propertyPath = null) Assert that value is a resource. |
|||
* @method AssertionChain isTraversable(string|callable $message = null, string $propertyPath = null) Assert that value is an array or a traversable object. |
|||
* @method AssertionChain keyExists(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array. |
|||
* @method AssertionChain keyIsset(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object using isset(). |
|||
* @method AssertionChain keyNotExists(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key does not exist in an array. |
|||
* @method AssertionChain length(int $length, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string has a given length. |
|||
* @method AssertionChain lessOrEqualThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less or equal than given limit. |
|||
* @method AssertionChain lessThan(mixed $limit, string|callable $message = null, string $propertyPath = null) Determines if the value is less than given limit. |
|||
* @method AssertionChain max(mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that a number is smaller as a given limit. |
|||
* @method AssertionChain maxCount(int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at most $count elements. |
|||
* @method AssertionChain maxLength(int $maxLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string value is not longer than $maxLength chars. |
|||
* @method AssertionChain methodExists(mixed $object, string|callable $message = null, string $propertyPath = null) Determines that the named method is defined in the provided object. |
|||
* @method AssertionChain min(mixed $minValue, string|callable $message = null, string $propertyPath = null) Assert that a value is at least as big as a given limit. |
|||
* @method AssertionChain minCount(int $count, string|callable $message = null, string $propertyPath = null) Assert that the countable have at least $count elements. |
|||
* @method AssertionChain minLength(int $minLength, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that a string is at least $minLength chars long. |
|||
* @method AssertionChain noContent(string|callable $message = null, string $propertyPath = null) Assert that value is empty. |
|||
* @method AssertionChain notBlank(string|callable $message = null, string $propertyPath = null) Assert that value is not blank. |
|||
* @method AssertionChain notContains(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string does not contains a sequence of chars. |
|||
* @method AssertionChain notEmpty(string|callable $message = null, string $propertyPath = null) Assert that value is not empty. |
|||
* @method AssertionChain notEmptyKey(string|int $key, string|callable $message = null, string $propertyPath = null) Assert that key exists in an array/array-accessible object and its value is not empty. |
|||
* @method AssertionChain notEq(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not equal (using ==). |
|||
* @method AssertionChain notInArray(array $choices, string|callable $message = null, string $propertyPath = null) Assert that value is not in array of choices. |
|||
* @method AssertionChain notIsInstanceOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is not instance of given class-name. |
|||
* @method AssertionChain notNull(string|callable $message = null, string $propertyPath = null) Assert that value is not null. |
|||
* @method AssertionChain notRegex(string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value does not match a regex. |
|||
* @method AssertionChain notSame(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are not the same (using ===). |
|||
* @method AssertionChain null(string|callable $message = null, string $propertyPath = null) Assert that value is null. |
|||
* @method AssertionChain numeric(string|callable $message = null, string $propertyPath = null) Assert that value is numeric. |
|||
* @method AssertionChain objectOrClass(string|callable $message = null, string $propertyPath = null) Assert that the value is an object, or a class that exists. |
|||
* @method AssertionChain phpVersion(mixed $version, string|callable $message = null, string $propertyPath = null) Assert on PHP version. |
|||
* @method AssertionChain propertiesExist(array $properties, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the properties all exist. |
|||
* @method AssertionChain propertyExists(string $property, string|callable $message = null, string $propertyPath = null) Assert that the value is an object or class, and that the property exists. |
|||
* @method AssertionChain range(mixed $minValue, mixed $maxValue, string|callable $message = null, string $propertyPath = null) Assert that value is in range of numbers. |
|||
* @method AssertionChain readable(string|callable $message = null, string $propertyPath = null) Assert that the value is something readable. |
|||
* @method AssertionChain regex(string $pattern, string|callable $message = null, string $propertyPath = null) Assert that value matches a regex. |
|||
* @method AssertionChain same(mixed $value2, string|callable $message = null, string $propertyPath = null) Assert that two values are the same (using ===). |
|||
* @method AssertionChain satisfy(callable $callback, string|callable $message = null, string $propertyPath = null) Assert that the provided value is valid according to a callback. |
|||
* @method AssertionChain scalar(string|callable $message = null, string $propertyPath = null) Assert that value is a PHP scalar. |
|||
* @method AssertionChain startsWith(string $needle, string|callable $message = null, string $propertyPath = null, string $encoding = 'utf8') Assert that string starts with a sequence of chars. |
|||
* @method AssertionChain string(string|callable $message = null, string $propertyPath = null) Assert that value is a string. |
|||
* @method AssertionChain subclassOf(string $className, string|callable $message = null, string $propertyPath = null) Assert that value is subclass of given class-name. |
|||
* @method AssertionChain true(string|callable $message = null, string $propertyPath = null) Assert that the value is boolean True. |
|||
* @method AssertionChain url(string|callable $message = null, string $propertyPath = null) Assert that value is an URL. |
|||
* @method AssertionChain uuid(string|callable $message = null, string $propertyPath = null) Assert that the given string is a valid UUID. |
|||
* @method AssertionChain version(string $operator, string $version2, string|callable $message = null, string $propertyPath = null) Assert comparison of two versions. |
|||
* @method AssertionChain writeable(string|callable $message = null, string $propertyPath = null) Assert that the value is something writeable. |
|||
*/ |
|||
class AssertionChain |
|||
{ |
|||
/** |
|||
* @var mixed |
|||
*/ |
|||
private $value; |
|||
|
|||
/** |
|||
* @var string|callable|null |
|||
*/ |
|||
private $defaultMessage; |
|||
|
|||
/** |
|||
* @var string|null |
|||
*/ |
|||
private $defaultPropertyPath; |
|||
|
|||
/** |
|||
* Return each assertion as always valid. |
|||
* |
|||
* @var bool |
|||
*/ |
|||
private $alwaysValid = false; |
|||
|
|||
/** |
|||
* Perform assertion on every element of array or traversable. |
|||
* |
|||
* @var bool |
|||
*/ |
|||
private $all = false; |
|||
|
|||
/** @var string|Assertion Class to use for assertion calls */ |
|||
private $assertionClassName = 'Assert\Assertion'; |
|||
|
|||
/** |
|||
* AssertionChain constructor. |
|||
* |
|||
* @param mixed $value |
|||
* @param string|callable|null $defaultMessage |
|||
* @param string|null $defaultPropertyPath |
|||
*/ |
|||
public function __construct($value, $defaultMessage = null, string $defaultPropertyPath = null) |
|||
{ |
|||
$this->value = $value; |
|||
$this->defaultMessage = $defaultMessage; |
|||
$this->defaultPropertyPath = $defaultPropertyPath; |
|||
} |
|||
|
|||
/** |
|||
* Call assertion on the current value in the chain. |
|||
* |
|||
* @param string $methodName |
|||
* @param array $args |
|||
* |
|||
* @return AssertionChain |
|||
*/ |
|||
public function __call($methodName, $args): AssertionChain |
|||
{ |
|||
if (true === $this->alwaysValid) { |
|||
return $this; |
|||
} |
|||
|
|||
if (!\method_exists($this->assertionClassName, $methodName)) { |
|||
throw new \RuntimeException("Assertion '".$methodName."' does not exist."); |
|||
} |
|||
|
|||
$reflClass = new ReflectionClass($this->assertionClassName); |
|||
$method = $reflClass->getMethod($methodName); |
|||
|
|||
\array_unshift($args, $this->value); |
|||
$params = $method->getParameters(); |
|||
|
|||
foreach ($params as $idx => $param) { |
|||
if (isset($args[$idx])) { |
|||
continue; |
|||
} |
|||
|
|||
if ('message' == $param->getName()) { |
|||
$args[$idx] = $this->defaultMessage; |
|||
} |
|||
|
|||
if ('propertyPath' == $param->getName()) { |
|||
$args[$idx] = $this->defaultPropertyPath; |
|||
} |
|||
} |
|||
|
|||
if ($this->all) { |
|||
$methodName = 'all'.$methodName; |
|||
} |
|||
|
|||
\call_user_func_array([$this->assertionClassName, $methodName], $args); |
|||
|
|||
return $this; |
|||
} |
|||
|
|||
/** |
|||
* Switch chain into validation mode for an array of values. |
|||
* |
|||
* @return AssertionChain |
|||
*/ |
|||
public function all(): AssertionChain |
|||
{ |
|||
$this->all = true; |
|||
|
|||
return $this; |
|||
} |
|||
|
|||
/** |
|||
* Switch chain into mode allowing nulls, ignoring further assertions. |
|||
* |
|||
* @return AssertionChain |
|||
*/ |
|||
public function nullOr(): AssertionChain |
|||
{ |
|||
if (null === $this->value) { |
|||
$this->alwaysValid = true; |
|||
} |
|||
|
|||
return $this; |
|||
} |
|||
|
|||
/** |
|||
* @param string $className |
|||
* |
|||
* @return $this |
|||
*/ |
|||
public function setAssertionClassName($className): AssertionChain |
|||
{ |
|||
if (!\is_string($className)) { |
|||
throw new LogicException('Exception class name must be passed as a string'); |
|||
} |
|||
|
|||
if (Assertion::class !== $className && !\is_subclass_of($className, Assertion::class)) { |
|||
throw new LogicException($className.' is not (a subclass of) '.Assertion::class); |
|||
} |
|||
|
|||
$this->assertionClassName = $className; |
|||
|
|||
return $this; |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* Assert |
|||
* |
|||
* LICENSE |
|||
* |
|||
* This source file is subject to the MIT license that is bundled |
|||
* with this package in the file LICENSE.txt. |
|||
* If you did not receive a copy of the license and are unable to |
|||
* obtain it through the world-wide-web, please send an email |
|||
* to kontakt@beberlei.de so I can send you a copy immediately. |
|||
*/ |
|||
|
|||
namespace Assert; |
|||
|
|||
use Throwable; |
|||
|
|||
interface AssertionFailedException extends Throwable |
|||
{ |
|||
/** |
|||
* @return string|null |
|||
*/ |
|||
public function getPropertyPath(); |
|||
|
|||
/** |
|||
* @return mixed |
|||
*/ |
|||
public function getValue(); |
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
public function getConstraints(): array; |
|||
} |
@ -0,0 +1,76 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* Assert |
|||
* |
|||
* LICENSE |
|||
* |
|||
* This source file is subject to the MIT license that is bundled |
|||
* with this package in the file LICENSE.txt. |
|||
* If you did not receive a copy of the license and are unable to |
|||
* obtain it through the world-wide-web, please send an email |
|||
* to kontakt@beberlei.de so I can send you a copy immediately. |
|||
*/ |
|||
|
|||
namespace Assert; |
|||
|
|||
class InvalidArgumentException extends \InvalidArgumentException implements AssertionFailedException |
|||
{ |
|||
/** |
|||
* @var string|null |
|||
*/ |
|||
private $propertyPath; |
|||
|
|||
/** |
|||
* @var mixed |
|||
*/ |
|||
private $value; |
|||
|
|||
/** |
|||
* @var array |
|||
*/ |
|||
private $constraints; |
|||
|
|||
public function __construct($message, $code, string $propertyPath = null, $value = null, array $constraints = []) |
|||
{ |
|||
parent::__construct($message, $code); |
|||
|
|||
$this->propertyPath = $propertyPath; |
|||
$this->value = $value; |
|||
$this->constraints = $constraints; |
|||
} |
|||
|
|||
/** |
|||
* User controlled way to define a sub-property causing |
|||
* the failure of a currently asserted objects. |
|||
* |
|||
* Useful to transport information about the nature of the error |
|||
* back to higher layers. |
|||
* |
|||
* @return string|null |
|||
*/ |
|||
public function getPropertyPath() |
|||
{ |
|||
return $this->propertyPath; |
|||
} |
|||
|
|||
/** |
|||
* Get the value that caused the assertion to fail. |
|||
* |
|||
* @return mixed |
|||
*/ |
|||
public function getValue() |
|||
{ |
|||
return $this->value; |
|||
} |
|||
|
|||
/** |
|||
* Get the constraints that applied to the failed assertion. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function getConstraints(): array |
|||
{ |
|||
return $this->constraints; |
|||
} |
|||
} |
@ -0,0 +1,230 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* Assert |
|||