ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\KeyValueStorage\Subject\SubjectId Class Reference

Identifies a subject within the provider that names it. More...

+ Collaboration diagram for ILIAS\KeyValueStorage\Subject\SubjectId:

Public Member Functions

 __construct (SubjectProvider $provider, private string $id)
 
 provider ()
 
 id ()
 
 providerClass ()
 

Data Fields

const int MAX_LENGTH = 128
 

Private Member Functions

 assertIdentifier (string $value, int $max_length, string $pattern, string $what)
 

Private Attributes

string $provider
 
string $provider_class
 

Detailed Description

Identifies a subject within the provider that names it.

KeyValueStorage validates the format only. It does not assign meaning to the id; that is up to the provider.

Definition at line 29 of file SubjectId.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\KeyValueStorage\Subject\SubjectId::__construct ( SubjectProvider  $provider,
private string  $id 
)

Definition at line 36 of file SubjectId.php.

37 {
38 $this->provider = $provider->name();
39 $this->provider_class = $provider::class;
40
41 $this->assertIdentifier(
42 $this->provider,
44 '/^[a-z][a-z0-9_]*$/',
45 'Subject provider name'
46 );
47 $this->assertIdentifier($id, self::MAX_LENGTH, '/^[a-z0-9_]+$/', 'Subject id');
48 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
assertIdentifier(string $value, int $max_length, string $pattern, string $what)
Definition: SubjectId.php:69
name()
Unique among all providers, a lowercase identifier, e.g.

References ILIAS\KeyValueStorage\Subject\SubjectId\assertIdentifier(), ILIAS\KeyValueStorage\Subject\SubjectProvider\MAX_NAME_LENGTH, ILIAS\KeyValueStorage\Subject\SubjectProvider\name(), and ILIAS\KeyValueStorage\Subject\SubjectId\provider().

+ Here is the call graph for this function:

Member Function Documentation

◆ assertIdentifier()

ILIAS\KeyValueStorage\Subject\SubjectId::assertIdentifier ( string  $value,
int  $max_length,
string  $pattern,
string  $what 
)
private

Definition at line 69 of file SubjectId.php.

69 : void
70 {
71 if ($value === '') {
72 throw new \InvalidArgumentException($what . ' must not be empty.');
73 }
74
75 $length = \mb_strlen($value, 'UTF-8');
76 if ($length > $max_length) {
77 throw new \InvalidArgumentException(
78 $what . ' must not exceed ' . $max_length . ' characters, got ' . $length . '.'
79 );
80 }
81
82 if (!\preg_match($pattern, $value)) {
83 throw new \InvalidArgumentException(
84 $what . ' must be a lowercase identifier, got "' . $value . '".'
85 );
86 }
87 }

References $pattern.

Referenced by ILIAS\KeyValueStorage\Subject\SubjectId\__construct().

+ Here is the caller graph for this function:

◆ id()

◆ provider()

◆ providerClass()

ILIAS\KeyValueStorage\Subject\SubjectId::providerClass ( )

Definition at line 64 of file SubjectId.php.

64 : string
65 {
67 }

References ILIAS\KeyValueStorage\Subject\SubjectId\$provider_class.

Referenced by ILIAS\KeyValueStorage\Internal\SubjectProviders\assertRegistered().

+ Here is the caller graph for this function:

Field Documentation

◆ $provider

string ILIAS\KeyValueStorage\Subject\SubjectId::$provider
private

Definition at line 33 of file SubjectId.php.

Referenced by ILIAS\KeyValueStorage\Subject\SubjectId\provider().

◆ $provider_class

string ILIAS\KeyValueStorage\Subject\SubjectId::$provider_class
private

Definition at line 34 of file SubjectId.php.

Referenced by ILIAS\KeyValueStorage\Subject\SubjectId\providerClass().

◆ MAX_LENGTH


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