ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilECSResult Class Reference
+ Collaboration diagram for ilECSResult:

Public Member Functions

 __construct (string $a_res, int $a_type=self::RESULT_TYPE_JSON)
 Constructor. More...
 
 setHTTPCode (int $a_code)
 set HTTP return code More...
 
 getHTTPCode ()
 get HTTP code More...
 
 getResult ()
 get result More...
 
 getResultType ()
 
 setHeaders (array $a_headers)
 Set header. More...
 
 getHeaders ()
 get headers More...
 

Data Fields

const RESULT_TYPE_JSON = 1
 
const RESULT_TYPE_URL_LIST = 2
 

Private Member Functions

 init (string $result_string, int $result_type)
 init result (json_decode) More...
 
 parseUriList (string $a_content)
 

Private Attributes

int $http_code = 0
 
int $result_type
 
 $result
 
array $headers = array()
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilECSResult.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSResult::__construct ( string  $a_res,
int  $a_type = self::RESULT_TYPE_JSON 
)

Constructor.

@access public

Parameters
stringresult_string
intresult type
Exceptions
ilECSConnectorException

Definition at line 44 of file class.ilECSResult.php.

45 {
46 $this->result_type = $a_type;
47
48 $this->init($a_res, $a_type);
49 }
init(string $result_string, int $result_type)
init result (json_decode)

References init().

+ Here is the call graph for this function:

Member Function Documentation

◆ getHeaders()

ilECSResult::getHeaders ( )

get headers

Definition at line 100 of file class.ilECSResult.php.

100 : array
101 {
102 return $this->headers ?: [];
103 }

◆ getHTTPCode()

ilECSResult::getHTTPCode ( )

get HTTP code

@access public

Definition at line 68 of file class.ilECSResult.php.

68 : int
69 {
70 return $this->http_code;
71 }

References $http_code.

◆ getResult()

ilECSResult::getResult ( )

get result

Returns
mixed JSON object, array of objects or false in case of errors.

Definition at line 78 of file class.ilECSResult.php.

79 {
80 return $this->result;
81 }

References $result.

◆ getResultType()

ilECSResult::getResultType ( )

Definition at line 83 of file class.ilECSResult.php.

83 : int
84 {
85 return $this->result_type;
86 }

References $result_type.

◆ init()

ilECSResult::init ( string  $result_string,
int  $result_type 
)
private

init result (json_decode)

Definition at line 108 of file class.ilECSResult.php.

108 : void
109 {
110 switch ($result_type) {
112 if ($result_string) {
113 $this->result = json_decode($result_string, false, 512, JSON_THROW_ON_ERROR);
114 } else {
115 $this->result = [];
116 }
117 break;
118
120 $this->result = $this->parseUriList($result_string);
121 break;
122 }
123 }
const RESULT_TYPE_URL_LIST
parseUriList(string $a_content)

References $result_type, parseUriList(), RESULT_TYPE_JSON, and RESULT_TYPE_URL_LIST.

Referenced by __construct().

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

◆ parseUriList()

ilECSResult::parseUriList ( string  $a_content)
private
Parameters
string$a_content
Returns
ilECSUriList

Definition at line 130 of file class.ilECSResult.php.

131 {
132 $list = new ilECSUriList();
133 $lines = explode("\n", $a_content);
134 foreach ($lines as $line) {
135 $line = trim($line);
136 if ($line === '') {
137 continue;
138 }
139 $uri_parts = explode("/", $line);
140 $list->add($line, (int) array_pop($uri_parts));
141 }
142
143 return $list;
144 }
Presentation of ecs uril (http://...campusconnect/courselinks)

Referenced by init().

+ Here is the caller graph for this function:

◆ setHeaders()

ilECSResult::setHeaders ( array  $a_headers)

Set header.

Parameters
array$a_headers

Definition at line 92 of file class.ilECSResult.php.

92 : void
93 {
94 $this->headers = $a_headers;
95 }

◆ setHTTPCode()

ilECSResult::setHTTPCode ( int  $a_code)

set HTTP return code

@access public

Parameters
stringhttp code

Definition at line 58 of file class.ilECSResult.php.

58 : void
59 {
60 $this->http_code = $a_code;
61 }

Field Documentation

◆ $headers

array ilECSResult::$headers = array()
private

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

◆ $http_code

int ilECSResult::$http_code = 0
private

Definition at line 29 of file class.ilECSResult.php.

Referenced by getHTTPCode().

◆ $result

ilECSResult::$result
private

Definition at line 31 of file class.ilECSResult.php.

Referenced by getResult().

◆ $result_type

int ilECSResult::$result_type
private

Definition at line 30 of file class.ilECSResult.php.

Referenced by getResultType(), and init().

◆ RESULT_TYPE_JSON

const ilECSResult::RESULT_TYPE_JSON = 1

Definition at line 26 of file class.ilECSResult.php.

Referenced by init().

◆ RESULT_TYPE_URL_LIST

const ilECSResult::RESULT_TYPE_URL_LIST = 2

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