Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       100.00%  | 
       13 / 13  | 
               | 
       100.00%  | 
       3 / 3  | 
       CRAP |         | 
       100.00%  | 
       1 / 1  | 
      
| EventLog |         | 
       100.00%  | 
       13 / 13  | 
               | 
       100.00%  | 
       3 / 3  | 
       3 |         | 
       100.00%  | 
       1 / 1  | 
      
| readByNameAndRef |         | 
       100.00%  | 
       6 / 6  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| writeEntity |         | 
       100.00%  | 
       4 / 4  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| deleteOutdated |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| 1 | <?php | 
| 2 | |
| 3 | /** | 
| 4 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | 
| 5 | **/ | 
| 6 | |
| 7 | declare(strict_types=1); | 
| 8 | |
| 9 | namespace BO\Zmsdb; | 
| 10 | |
| 11 | use BO\Zmsentities\EventLog as EventLogEntity; | 
| 12 | use BO\Zmsentities\Collection\EventLogList as EventLogCollection; | 
| 13 | use PDO; | 
| 14 | |
| 15 | class EventLog extends Base | 
| 16 | { | 
| 17 | /** | 
| 18 | * @param string $name | 
| 19 | * @param string $reference | 
| 20 | * @return EventLogCollection | 
| 21 | */ | 
| 22 | public function readByNameAndRef(string $name, string $reference): EventLogCollection | 
| 23 | { | 
| 24 | $query = new Query\EventLog(Query\Base::SELECT); | 
| 25 | $query | 
| 26 | ->addEntityMapping() | 
| 27 | ->addNameComparison($name) | 
| 28 | ->addReferenceComparison($reference); | 
| 29 | |
| 30 | return $this->fetchList($query, new EventLogEntity(), new EventLogCollection()); | 
| 31 | } | 
| 32 | |
| 33 | /** | 
| 34 | * @param EventLogEntity $entity | 
| 35 | * @return bool | 
| 36 | */ | 
| 37 | public function writeEntity(EventLogEntity $entity) | 
| 38 | { | 
| 39 | $query = new Query\EventLog(Query\Base::INSERT); | 
| 40 | $values = $query->reverseEntityMapping($entity); | 
| 41 | $query->addValues($values); | 
| 42 | |
| 43 | return $this->writeItem($query); | 
| 44 | } | 
| 45 | |
| 46 | public function deleteOutdated(): bool | 
| 47 | { | 
| 48 | $deleteQuery = new Query\EventLog(Query\Base::DELETE); | 
| 49 | $deleteQuery->addExpirationCondition(); | 
| 50 | |
| 51 | return $this->deleteItem($deleteQuery); | 
| 52 | } | 
| 53 | } |