diff options
author | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-09-01 14:03:09 +0200 |
---|---|---|
committer | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-09-01 14:03:09 +0200 |
commit | 53bbb49360598439f3cc2dd26532ed9e7b17ef7e (patch) | |
tree | 78d8f74d05e2f7d15492c0710427419754460873 /lib/SimpleSAML/Utils/Attributes.php | |
parent | 5a04fc54806a932677eb4ceef0e5d99d7ad05180 (diff) | |
download | simplesamlphp-53bbb49360598439f3cc2dd26532ed9e7b17ef7e.zip simplesamlphp-53bbb49360598439f3cc2dd26532ed9e7b17ef7e.tar.gz simplesamlphp-53bbb49360598439f3cc2dd26532ed9e7b17ef7e.tar.bz2 |
SimpleSAML\Utils\Attributes::getExpectedAttribute(): Check if the attribute has any values, and raise an exception if not.
Diffstat (limited to 'lib/SimpleSAML/Utils/Attributes.php')
-rw-r--r-- | lib/SimpleSAML/Utils/Attributes.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/SimpleSAML/Utils/Attributes.php b/lib/SimpleSAML/Utils/Attributes.php index d4b6d28..266084a 100644 --- a/lib/SimpleSAML/Utils/Attributes.php +++ b/lib/SimpleSAML/Utils/Attributes.php @@ -43,9 +43,13 @@ class Attributes $attribute = $attributes[$expected]; if (!is_array($attribute)) { - throw new \SimpleSAML_Error_Exception('The attributes array is not normalized, values should be arrays.'); + throw new \InvalidArgumentException('The attributes array is not normalized, values should be arrays.'); } - if (count($attribute) > 1) { + + if (count($attribute) === 0) { + throw new \SimpleSAML_Error_Exception("Empty attribute '".$expected."'.'"); + + } elseif (count($attribute) > 1) { if ($allow_multiple === false) { throw new \SimpleSAML_Error_Exception( 'More than one value found for the attribute, multiple values not allowed.' |