/**
  * @param string $attributeName the name of the attribute to attempt to get the value of
  * @param mixed  $defaultValue  the value to return should the assertion not contain the attribute
  * @return string[]|mixed string[] if the attribute is found, the given default value otherwise
  */
 public function getAttributeValue($attributeName, $defaultValue = null)
 {
     $attributeDefinition = $this->attributeDictionary->getAttributeDefinition($attributeName);
     if (!$this->attributeSet->containsAttributeDefinedBy($attributeDefinition)) {
         return $defaultValue;
     }
     $attribute = $this->attributeSet->getAttributeByDefinition($attributeDefinition);
     return $attribute->getValue();
 }
 /**
  * Attempt to get an attribute from the assertion.
  *
  * @param string $name
  * @param null   $default
  * @return mixed|null
  */
 public function getAttribute($name, $default = null)
 {
     $attributeDefinition = $this->attributeDictionary->getAttributeDefinition($name);
     // try first by urn:mace, then by urn:oid
     if ($this->assertionAttributes->has($attributeDefinition->getUrnMace())) {
         $attribute = $this->assertionAttributes->get($attributeDefinition->getUrnMace());
     } elseif ($this->assertionAttributes->has($attributeDefinition->getUrnOid())) {
         $attribute = $this->assertionAttributes->get($attributeDefinition->getUrnOid());
     } else {
         return $default;
     }
     // if it is singular, it should return the single value if it has a value
     if ($attributeDefinition->getMultiplicity() === AttributeDefinition::MULTIPLICITY_SINGLE) {
         $count = count($attribute);
         if ($count > 1) {
             throw new UnexpectedValueException(sprintf('AttributeDefinition "%s" has a single-value multiplicity, yet returned' . ' "%d" values', $attributeDefinition->getName(), count($attribute)));
         } elseif ($count === 0) {
             $attribute = null;
         } else {
             $attribute = reset($attribute);
         }
     }
     return $attribute;
 }