ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Data\Factory Class Reference

Builds data types. More...

+ Inheritance diagram for ILIAS\Data\Factory:
+ Collaboration diagram for ILIAS\Data\Factory:

Public Member Functions

 ok ($value)
 Get an ok result. More...
 
 error ($e)
 Get an error result. More...
 
 color ($value)
 Color is a data type representing a color in HTML. More...
 
 uri ($uri_string)
 Object representing an uri valid according to RFC 3986 with restrictions imposed on valid characters and obliagtory parts. More...
 
 dataSize ($size, string $unit=null)
 Represents the size of some data. More...
 
 password ($pass)
 Get a password. More...
 
 clientId (string $clientId)
 
 refId (int $ref_id)
 
 alphanumeric ($value)
 
 positiveInteger (int $value)
 
 dateFormat ()
 
 range (int $start, int $length)
 
 order (string $subject, $direction)
 

Private Attributes

 $colorfactory
 cache for color factory. More...
 

Detailed Description

Member Function Documentation

◆ alphanumeric()

ILIAS\Data\Factory::alphanumeric (   $value)
Parameters
$value
Returns
Alphanumeric

Definition at line 135 of file Factory.php.

135  : Alphanumeric
136  {
137  return new Alphanumeric($value);
138  }

◆ clientId()

ILIAS\Data\Factory::clientId ( string  $clientId)
Parameters
string$clientId
Returns
ClientId

Definition at line 116 of file Factory.php.

116  : ClientId
117  {
118  return new ClientId($clientId);
119  }

◆ color()

ILIAS\Data\Factory::color (   $value)

Color is a data type representing a color in HTML.

Construct a color with a hex-value or list of RGB-values.

Parameters
string|int[]$value
Returns
Color

Definition at line 55 of file Factory.php.

56  {
57  if (!$this->colorfactory) {
58  $this->colorfactory = new Color\Factory();
59  }
60  return $this->colorfactory->build($value);
61  }

◆ dataSize()

ILIAS\Data\Factory::dataSize (   $size,
string  $unit = null 
)

Represents the size of some data.

Parameters
string | int$sizestring might be a string like "126 MB"
Exceptions

Definition at line 83 of file Factory.php.

References ILIAS\Data\DataSize\$abbreviations, and $size.

83  : DataSize
84  {
85  if (is_string($size)) {
86  $match = [];
87  if (!preg_match("/(\d+)\s*([a-zA-Z]+)/", $size, $match)) {
88  throw \InvalidArgumentException("'$size' can't be interpreted as data size.");
89  }
90  return $this->dataSize((int) $match[1], $match[2]);
91  }
92  if (is_int($size) && (is_null($unit) || !array_key_exists($unit, DataSize::$abbreviations))) {
93  throw new \InvalidArgumentException(
94  "Expected second argument to be a unit for data, '$unit' is unknown."
95  );
96  }
97  $unit_size = DataSize::$abbreviations[$unit];
98  return new DataSize($size * $unit_size, $unit_size);
99  }
$size
Definition: RandomTest.php:84
static $abbreviations
Definition: DataSize.php:69
dataSize($size, string $unit=null)
Represents the size of some data.
Definition: Factory.php:83

◆ dateFormat()

ILIAS\Data\Factory::dateFormat ( )
Returns
DateFormat

Definition at line 152 of file Factory.php.

References $builder.

Referenced by ilStudyProgrammeDeadlineSettings\toFormInput(), and ilStudyProgrammeValidityOfAchievedQualificationSettings\toFormInput().

153  {
155  return new DateFormat\Factory($builder);
156  }
Factory for Date Formats.
Definition: Factory.php:9
Builds a Date Format with split up elements to ease conversion.
$builder
Definition: parser.php:5
+ Here is the caller graph for this function:

◆ error()

ILIAS\Data\Factory::error (   $e)

Get an error result.

Parameters
string | \Exception$error
Returns
Result

Definition at line 43 of file Factory.php.

References Vendor\Package\$e.

44  {
45  return new Result\Error($e);
46  }

◆ ok()

ILIAS\Data\Factory::ok (   $value)

Get an ok result.

Parameters
mixed$value
Returns
Result

Definition at line 32 of file Factory.php.

33  {
34  return new Result\Ok($value);
35  }

◆ order()

ILIAS\Data\Factory::order ( string  $subject,
  $direction 
)
Parameters
mixed$directionOrder::ASC|Order::DESC

Definition at line 171 of file Factory.php.

171  : Order
172  {
173  return new Order($subject, $direction);
174  }

◆ password()

ILIAS\Data\Factory::password (   $pass)

Get a password.

Parameters
string
Returns
Password

Definition at line 107 of file Factory.php.

References $pass.

108  {
109  return new Password($pass);
110  }

◆ positiveInteger()

ILIAS\Data\Factory::positiveInteger ( int  $value)
Parameters
int$value
Returns
PositiveInteger

Definition at line 144 of file Factory.php.

144  : PositiveInteger
145  {
146  return new PositiveInteger($value);
147  }

◆ range()

ILIAS\Data\Factory::range ( int  $start,
int  $length 
)
Parameters
int$start
int$length
Returns
Range

Definition at line 163 of file Factory.php.

163  : Range
164  {
165  return new Range($start, $length);
166  }

◆ refId()

ILIAS\Data\Factory::refId ( int  $ref_id)
Parameters
int$ref_id
Returns
ReferenceId

Definition at line 126 of file Factory.php.

126  : ReferenceId
127  {
128  return new ReferenceId($ref_id);
129  }

◆ uri()

ILIAS\Data\Factory::uri (   $uri_string)

Object representing an uri valid according to RFC 3986 with restrictions imposed on valid characters and obliagtory parts.

Parameters
string$uri_string
Returns
URI

Definition at line 71 of file Factory.php.

72  {
73  return new URI($uri_string);
74  }

Field Documentation

◆ $colorfactory

ILIAS\Data\Factory::$colorfactory
private

cache for color factory.

Definition at line 24 of file Factory.php.


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