Example #1
0
 /**
  * Initializes this component.
  *
  * @param Connector $connector The connector signed in.
  * @param string $login The login of the user to load data, if null, it will take the signed in user.
  * @throws \Exception If the Connector is not signed in.
  */
 public function __construct(Connector $connector, $login = null)
 {
     $connector->checkSignedIn();
     $this->connector = $connector;
     // Retrieving information about the specified user or signed in user
     if ($login == null) {
         $url = str_replace('{LOGIN}', $this->connector->getUser()->getLogin(), self::URL_NETSOUL);
     } else {
         $url = str_replace('{LOGIN}', $login, self::URL_NETSOUL);
     }
     $response = $this->connector->request($url);
     $this->data = DataExtractor::retrieve($response);
     // Parsing the data
     $logs = array();
     foreach ($this->data as $log) {
         // Building the dates
         $datetime = null;
         if ($timestamp = DataExtractor::extract($log, array(0))) {
             $datetime = new \DateTime();
             $datetime->setTimestamp($timestamp);
         }
         // Building the log
         $log = array('timestamp' => $timestamp, 'datetime' => $datetime, 'time_active' => DataExtractor::extract($log, array(1)), 'time_inactive' => DataExtractor::extract($log, array(2)), 'timeout_active' => DataExtractor::extract($log, array(3)), 'timeout_inactive' => DataExtractor::extract($log, array(4)), 'time_average' => DataExtractor::extract($log, array(5)));
         // Adding the log the temporary array
         $logs[$log['timestamp']] = $log;
     }
     // Replace the temporary array
     $this->data = $logs;
 }
Example #2
0
 /**
  * Obtains the promotion
  *
  * @return null|int
  */
 public function getPromotion()
 {
     return DataExtractor::extract($this->data, array('promo'));
 }
Example #3
0
 /**
  * Obtains the description.
  *
  * @return string|null
  */
 public function getDescription()
 {
     return DataExtractor::extract($this->data, array('description'));
 }