ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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.

public

Parameters
stringresult_string
intresult type
Exceptions
ilECSConnectorException

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

References init().

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)
+ 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

public

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

References $http_code.

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

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

References $result.

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

◆ getResultType()

ilECSResult::getResultType ( )

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

References $result_type.

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

◆ init()

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

init result (json_decode)

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

References parseUriList().

Referenced by __construct().

108  : void
109  {
110  switch ($result_type) {
111  case self::RESULT_TYPE_JSON:
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 
119  case self::RESULT_TYPE_URL_LIST:
120  $this->result = $this->parseUriList($result_string);
121  break;
122  }
123  }
parseUriList(string $a_content)
+ 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.

Referenced by init().

130  : \ilECSUriList
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)
+ 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

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().

◆ RESULT_TYPE_JSON

const ilECSResult::RESULT_TYPE_JSON = 1

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

◆ RESULT_TYPE_URL_LIST

const ilECSResult::RESULT_TYPE_URL_LIST = 2

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