ILIAS  release_7 Revision v7.30-3-g800a261c036
ilTermsOfServiceUserHasCountryCriterion Class Reference

Class ilTermsOfServiceUserHasCountryCriterion. More...

+ Inheritance diagram for ilTermsOfServiceUserHasCountryCriterion:
+ Collaboration diagram for ilTermsOfServiceUserHasCountryCriterion:

Public Member Functions

 __construct (array $countryCodes)
 ilTermsOfServiceUserHasCountryCriterion constructor. More...
 
 getTypeIdent ()
 Returns a unique id of the criterion type.
Returns
string
More...
 
 hasUniqueNature ()
 Returns whether or not a criterion is unique by it's nature.Example: "User Language". A user account can only have one profile language .

Returns
bool
More...
 
 evaluate (ilObjUser $user, ilTermsOfServiceCriterionConfig $config)
 
Parameters
ilObjUser$user
ilTermsOfServiceCriterionConfig$config
Returns
bool
More...
 
 ui (ilLanguage $lng)
 
Parameters
ilLanguage$lng
Returns
ilTermsOfServiceCriterionTypeGUI
More...
 

Protected Attributes

 $countryCodes = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceUserHasCountryCriterion::__construct ( array  $countryCodes)

ilTermsOfServiceUserHasCountryCriterion constructor.

Parameters
string[]$countryCodes

Definition at line 17 of file class.ilTermsOfServiceUserHasCountryCriterion.php.

References $countryCodes.

Member Function Documentation

◆ evaluate()

ilTermsOfServiceUserHasCountryCriterion::evaluate ( ilObjUser  $user,
ilTermsOfServiceCriterionConfig  $config 
)

Parameters
ilObjUser$user
ilTermsOfServiceCriterionConfig$config
Returns
bool

Implements ilTermsOfServiceCriterionType.

Definition at line 41 of file class.ilTermsOfServiceUserHasCountryCriterion.php.

References $result, and ilObjUser\getSelectedCountry().

Referenced by ilTermsOfServiceUserHasCountryCriterionTest\testEvaluationFailsIfUserCountryDoesNotMatchDefinedLanguage(), and ilTermsOfServiceUserHasCountryCriterionTest\testEvaluationSucceedsIfUserCountryDoesMatchDefinedLanguage().

41  : bool
42  {
43  $country = $config['country'] ?? '';
44 
45  if (!is_string($country) || 2 !== strlen($country) || !is_string($user->getSelectedCountry())) {
46  return false;
47  }
48 
49  $result = strtolower($country) === strtolower($user->getSelectedCountry());
50 
51  return $result;
52  }
$result
getSelectedCountry()
Get selected country (selection drop down)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTypeIdent()

ilTermsOfServiceUserHasCountryCriterion::getTypeIdent ( )

Returns a unique id of the criterion type.

Returns
string

Implements ilTermsOfServiceCriterionType.

Definition at line 25 of file class.ilTermsOfServiceUserHasCountryCriterion.php.

Referenced by ilTermsOfServiceUserHasCountryCriterionTest\testFormUserInterfaceElementsAreProperlyBuilt(), and ilTermsOfServiceUserHasCountryCriterionTest\testValuesFromFormUserInterfaceElementsCanBeRetrieved().

25  : string
26  {
27  return 'usr_country';
28  }
+ Here is the caller graph for this function:

◆ hasUniqueNature()

ilTermsOfServiceUserHasCountryCriterion::hasUniqueNature ( )

Returns whether or not a criterion is unique by it's nature.Example: "User Language". A user account can only have one profile language .

Returns
bool

Implements ilTermsOfServiceCriterionType.

Definition at line 33 of file class.ilTermsOfServiceUserHasCountryCriterion.php.

33  : bool
34  {
35  return true;
36  }

◆ ui()

Field Documentation

◆ $countryCodes

ilTermsOfServiceUserHasCountryCriterion::$countryCodes = []
protected

Definition at line 11 of file class.ilTermsOfServiceUserHasCountryCriterion.php.

Referenced by __construct().


The documentation for this class was generated from the following file: