ILIAS  release_7 Revision v7.30-3-g800a261c036
ilGeoLocationCalculator.php
Go to the documentation of this file.
1<?php
2
4{
6 protected $geo_repository;
7
8 public function __construct(ilGeoLocationRepository $a_geo_repository)
9 {
10 $this->geo_repository = $a_geo_repository;
11 }
12
13 public function calculateTimeTillNextExpiredGeoLocationAt(float $latitude, float $longitude)
14 {
15 $geo_locations = $this->geo_repository->getGeoLocationsByCoordinates($latitude, $longitude);
16
17 if (count($geo_locations) === 0) {
18 return null;
19 }
20
21 $current = array_shift($geo_locations);
22
23 foreach ($geo_locations as $geo_location) {
24 if ($current->getExpirationAsTimestamp() >= $geo_location->getExpirationAsTimestamp()) {
25 $current = $geo_location;
26 }
27 }
28
29 return $geo_location;
30 }
31}
An exception for terminatinating execution or to throw for unit testing.
__construct(ilGeoLocationRepository $a_geo_repository)
calculateTimeTillNextExpiredGeoLocationAt(float $latitude, float $longitude)
This code is just an example for the Repository Pattern! It is a basic interface to the 'ilGeoLocatio...