ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
ILIAS\Data\Description\DValue Class Reference
+ Inheritance diagram for ILIAS\Data\Description\DValue:
+ Collaboration diagram for ILIAS\Data\Description\DValue:

Public Member Functions

 __construct (Text\SimpleDocumentMarkdown $description, protected ValueType $type,)
 
 getType ()
 
 getPrimitiveRepresentation (mixed $data)
 
- Public Member Functions inherited from ILIAS\Data\Description\Description
 __construct (protected ?Text\SimpleDocumentMarkdown $description,)
 
 getDescription ()
 
 getPrimitiveRepresentation (mixed $data)
 Each of the types that can be described has a canonical representation created from primitive PHP types. More...
 
 matches (mixed $data)
 

Detailed Description

Definition at line 25 of file DValue.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\Description\DValue::__construct ( Text\SimpleDocumentMarkdown  $description,
protected ValueType  $type 
)

Definition at line 27 of file DValue.php.

References ILIAS\GlobalScreen\Provider\__construct().

30  {
31  parent::__construct($description);
32  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getPrimitiveRepresentation()

ILIAS\Data\Description\DValue::getPrimitiveRepresentation ( mixed  $data)

Definition at line 39 of file DValue.php.

References $data, and ILIAS\Data\Description\NULL.

39  : mixed
40  {
41  switch ($this->type) {
42  case ValueType::INT:
43  if (!is_int($data)) {
44  return fn() => yield "Expected an integer.";
45  }
46  return $data;
47 
48  case ValueType::FLOAT:
49  if (!is_float($data)) {
50  return fn() => yield "Expected a float.";
51  }
52  return $data;
53 
54  case ValueType::STRING:
55  if (!is_string($data)) {
56  return fn() => yield "Expected a string.";
57  }
58  return $data;
59 
60  case ValueType::DATETIME:
61  if (!$data instanceof \DateTimeImmutable) {
62  return fn() => yield "Expected a \\DateTimeImmutable.";
63  }
64  return $data;
65 
66  case ValueType::BOOL:
67  if (!is_bool($data)) {
68  return fn() => yield "Expected a bool.";
69  }
70  return $data;
71 
72  case ValueType::NULL:
73  if (!is_null($data)) {
74  return fn() => yield "Expected null.";
75  }
76  return $data;
77 
78  default:
79  throw new \LogicException("Unmatch type.");
80  }
81  }

◆ getType()

ILIAS\Data\Description\DValue::getType ( )

Definition at line 34 of file DValue.php.

34  : ValueType
35  {
36  return $this->type;
37  }

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