/** * @param string $entityId */ public function __construct($entityId) { Assert::notEmpty($entityId); Assert::string($entityId); Assert::notBlank($entityId); $this->entityId = $entityId; }
public function findAllFor($userId) { Assert::string($userId, 'User ID "%s" expected to be string, type %s given.'); Assert::notEmpty($userId, 'User ID "%s" is empty, but non empty value was expected.'); $consentListJson = $this->apiClient->read('consent/%s', [$userId]); return ConsentListFactory::createListFromMetadata($consentListJson); }
/** * @param string $nameId * @param AttributeSet $attributes * @param EntityId[] $authenticatingAuthorities */ private function __construct($nameId, AttributeSet $attributes, array $authenticatingAuthorities) { Assert::string($nameId); Assert::allIsInstanceOf($authenticatingAuthorities, '\\OpenConext\\Profile\\Value\\EntityId'); $this->nameId = $nameId; $this->attributes = $attributes; $this->authenticatingAuthorities = $authenticatingAuthorities; }
/** * @param string $locale * @return string */ public function getLocaleAwareEntityName($locale) { Assert::string($locale); if ($this->displayName->hasFilledTranslationForLocale($locale)) { return $this->displayName->getTranslation($locale); } return $this->entity->getEntityId()->getEntityId(); }
/** * @param mixed $data * @return ContactPerson * * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ private static function createContactPerson($data) { Assert::isArray($data, 'Contact person JSON structure must be an associative array, got %s'); Assert::keyExists($data, 'contact_type', 'Contact person JSON structure must contain key "contact_type"'); if (!array_key_exists('email_address', $data)) { return new ContactPerson(new ContactType($data['contact_type'])); } return new ContactPerson(new ContactType($data['contact_type']), new ContactEmailAddress($data['email_address'])); }
/** * @test * @group Assert * @dataProvider matchingKeysProvider */ public function matching_keys_do_not_trigger_an_exception($givenArray, $expectedKeys) { $exceptionIsThrown = false; try { Assert::keysAre($givenArray, $expectedKeys); } catch (AssertionFailedException $e) { $exceptionIsThrown = true; } $this->assertFalse($exceptionIsThrown); }
/** * @param array $descriptor * @return Entity */ public static function fromDescriptor(array $descriptor) { Assert::count($descriptor, 2); switch ($descriptor[1]) { case 'sp': return new Entity(new EntityId($descriptor[0]), EntityType::SP()); case 'idp': return new Entity(new EntityId($descriptor[0]), EntityType::IdP()); default: throw new LogicException('Entity descriptor type neither "sp" nor "idp"'); } }
/** * @param TranslatorInterface $translator * @param array $locales * @param array $helpUrls * @param array $platformUrls * @param array $termsOfServiceUrls * @param array $profileExplanationImageUrls * @param array $attributeInformationUrls */ public function __construct(TranslatorInterface $translator, array $locales, array $helpUrls, array $platformUrls, array $termsOfServiceUrls, array $profileExplanationImageUrls, array $attributeInformationUrls) { Assert::keysAre($helpUrls, $locales); Assert::keysAre($platformUrls, $locales); Assert::keysAre($termsOfServiceUrls, $locales); Assert::keysAre($profileExplanationImageUrls, $locales); Assert::keysAre($attributeInformationUrls, $locales); $this->translator = $translator; $this->helpUrls = $helpUrls; $this->platformUrls = $platformUrls; $this->termsOfServiceUrls = $termsOfServiceUrls; $this->profileExplanationImageUrls = $profileExplanationImageUrls; $this->attributeInformationUrls = $attributeInformationUrls; }
/** * @param mixed $data * @return ServiceProvider */ private static function createServiceProvider($data) { Assert::keyExists($data, 'entity_id', 'Consent JSON structure must contain key "entity_id"'); Assert::keyExists($data, 'display_name', 'Consent JSON structure must contain key "display_name"'); Assert::keyExists($data, 'eula_url', 'Consent JSON structure must contain key "eula_url"'); Assert::keyExists($data, 'support_email', 'Consent JSON structure must contain key "support_email"'); $entity = new Entity(new EntityId($data['entity_id']), EntityType::SP()); $displayName = new DisplayName($data['display_name']); $eulaUrl = null; $supportEmail = null; if ($data['eula_url'] !== null) { $eulaUrl = new Url($data['eula_url']); } if ($data['support_email'] !== null) { $supportEmail = new ContactEmailAddress($data['support_email']); } return new ServiceProvider($entity, $displayName, $eulaUrl, $supportEmail); }
/** * @param string $locale * @return bool */ public function hasFilledTranslationForLocale($locale) { Assert::string($locale, 'Locale must be string', 'locale'); return array_key_exists($locale, $this->translations) && trim($this->translations[$locale]) !== ''; }
/** * @param string $returnUrl * @return \Symfony\Component\Form\FormView */ public function getLocalePreferenceForm($returnUrl) { Assert::string($returnUrl); $form = $this->formFactory->create('profile_switch_locale', null, ['return_url' => $returnUrl]); return $form->createView(); }
/** * @param string $type */ public function __construct($type) { Assert::inArray($type, [self::TYPE_SP, self::TYPE_IDP]); $this->type = $type; }
/** * @param string $locale */ public function __construct($locale) { Assert::string($locale); Assert::notEmpty($locale); $this->locale = $locale; }
/** * @param string $value */ public function setValue($value) { Assert::string($value); $this->cookieValue = $value; }
/** * @param string $emailAddress */ public function __construct($emailAddress) { Assert::string($emailAddress, 'E-mail address "%s" must be a string'); Assert::email($emailAddress); $this->emailAddress = $emailAddress; }
/** * @param string $consentType */ private function __construct($consentType) { Assert::choice($consentType, [ConsentType::TYPE_EXPLICIT, ConsentType::TYPE_IMPLICIT], '"%s" is not one of the valid ConsentTypes: %s'); $this->consentType = $consentType; }
/** * @param string $contactType */ public function __construct($contactType) { Assert::string($contactType); Assert::choice($contactType, [self::TYPE_TECHNICAL, self::TYPE_SUPPORT, self::TYPE_ADMINISTRATIVE, self::TYPE_BILLING, self::TYPE_OTHER], '"%s" is not one of the valid ContactTypes: %s'); $this->contactType = $contactType; }