ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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)
 
 openedIntegerInterval (int $minimum, int $maximum)
 
 closedIntegerInterval (int $minimum, int $maximum)
 
 openedFloatInterval (float $minimum, float $maximum)
 
 closedFloatInterval (float $minimum, float $maximum)
 
 dateFormat ()
 

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 }

◆ closedFloatInterval()

ILIAS\Data\Factory::closedFloatInterval ( float  $minimum,
float  $maximum 
)
Parameters
float$minimum
float$maximum
Returns
ClosedFloatInterval

Definition at line 184 of file Factory.php.

184 : ClosedFloatInterval
185 {
186 return new ClosedFloatInterval($minimum, $maximum);
187 }

◆ closedIntegerInterval()

ILIAS\Data\Factory::closedIntegerInterval ( int  $minimum,
int  $maximum 
)
Parameters
int$minimum
int$maximum
Returns
ClosedIntegerInterval

Definition at line 164 of file Factory.php.

164 : ClosedIntegerInterval
165 {
166 return new ClosedIntegerInterval($minimum, $maximum);
167 }

◆ 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

InvalidArgumentException if first argument is int and second is not a valid unit.

Exceptions

InvalidArgumentException if string size can't be interpreted

Definition at line 83 of file Factory.php.

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

References ILIAS\Data\DataSize\$abbreviations, $size, and ILIAS\Data\Factory\dataSize().

Referenced by ILIAS\Data\Factory\dataSize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dateFormat()

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

Definition at line 192 of file Factory.php.

193 {
195 return new DateFormat\Factory($builder);
196 }
Factory for Date Formats.
Definition: Factory.php:10
Builds a Date Format with split up elements to ease conversion.
$builder
Definition: parser.php:5

References $builder.

◆ error()

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

Get an error result.

Parameters
string | \Exception$error
Returns
Result

Definition at line 43 of file Factory.php.

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

References Vendor\Package\$e.

◆ 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 }

◆ openedFloatInterval()

ILIAS\Data\Factory::openedFloatInterval ( float  $minimum,
float  $maximum 
)
Parameters
float$minimum
float$maximum
Returns
Float

Definition at line 174 of file Factory.php.

174 : OpenedFloatInterval
175 {
176 return new OpenedFloatInterval($minimum, $maximum);
177 }

◆ openedIntegerInterval()

ILIAS\Data\Factory::openedIntegerInterval ( int  $minimum,
int  $maximum 
)
Parameters
int$minimum
int$maximum
Returns
OpenedIntegerInterval

Definition at line 154 of file Factory.php.

154 : OpenedIntegerInterval
155 {
156 return new OpenedIntegerInterval($minimum, $maximum);
157 }

◆ password()

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

Get a password.

Parameters
string
Returns
Password

Definition at line 107 of file Factory.php.

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

References $pass.

◆ 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 }

◆ 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: