ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCertificateMigrationInformationObject.php
Go to the documentation of this file.
1 <?php
2 /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
29 {
31  private $id;
32 
34  private $usr_id;
35 
37  private $lock;
38 
40  private $found_items;
41 
44 
46  private $progress;
47 
49  private $state;
50 
52  private $starting_time;
53 
55  private $finished_time;
56 
61  public function __construct(array $data)
62  {
63  $this->setDataByArray($data);
64  }
65 
69  public function getId() : int
70  {
71  return isset($this->id) ? $this->id : 0;
72  }
73 
77  public function getUserId()
78  {
79  return $this->usr_id;
80  }
81 
85  public function getLock() : bool
86  {
87  return isset($this->lock) ? $this->lock : false;
88  }
89 
93  public function getProgressedItems() : int
94  {
95  return isset($this->processed_items) ? $this->processed_items : 0;
96  }
97 
101  public function getFoundItems() : int
102  {
103  return isset($this->found_items) ? $this->found_items : 0;
104  }
105 
109  public function getProgress() : int
110  {
111  return isset($this->progress) ? $this->progress : 0;
112  }
113 
117  public function getState() : string
118  {
119  return isset($this->state) ? $this->state : '';
120  }
121 
125  public function getStartingTime() : int
126  {
127  return isset($this->starting_time) ? $this->starting_time : 0;
128  }
129 
133  public function getFinishedTime() : int
134  {
135  return isset($this->finished_time) ? $this->finished_time : 0;
136  }
137 
141  public function getProcessingTime() : int
142  {
143  return $this->getFinishedTime() - $this->getStartingTime();
144  }
145 
149  public function getDataAsArray() : array
150  {
151  return [
152  'id' => $this->getId(),
153  'usr_id' => $this->getUserId(),
154  'lock' => (int) $this->getLock(),
155  'found_items' => $this->getFoundItems(),
156  'processed_items' => $this->getProgressedItems(),
157  'progress' => $this->getProgress(),
158  'state' => $this->getState(),
159  'started_ts' => $this->getStartingTime(),
160  'finished_ts' => $this->getFinishedTime(),
161  ];
162  }
163 
168  private function setDataByArray(array $data)
169  {
170  $this->id = $data['id'];
171  $this->usr_id = $data['usr_id'];
172  $this->lock = ($data['lock'] === true || $data['lock'] === 1);
173  $this->found_items = $data['found_items'];
174  $this->processed_items = $data['processed_items'];
175  $this->progress = $data['progress'];
176  $this->state = $data['state'];
177  $this->starting_time = $data['started_ts'];
178  $this->finished_time = $data['finished_ts'];
179  }
180 }
__construct(array $data)
ilCertificateMigrationInformationObject constructor.
$data
Definition: bench.php:6