Lines 0.00% 0 / 12
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ItemNeedsUpdateTrait 0.00% 0 / 12 0.00% 0 / 1 20 0.00% 0 / 1
 itemNeedsUpdate 0.00% 0 / 12 0.00% 0 / 1 20
1<?php
2
3namespace BO\Zmsdldb\Importer;
4
5/**
6 *
7 */
8trait ItemNeedsUpdateTrait
9{
10    public function itemNeedsUpdate(int $objectId, string $locale, string $objectHash, string $type): bool
11    {
12        try {
13            $statment = $this->getPDOAccess()->prepare(
14                "SELECT count(1) AS count FROM meta WHERE object_id = ? AND locale = ? AND hash = ? AND type = ?"
15            );
16            $result = $statment->execute([$objectId, $locale, $objectHash, $type]);
17
18            $needsUpdate = false;
19            if ($result) {
20                $count = $statment->fetchColumn();
21                if ($count != 1) {
22                    $needsUpdate = true;
23                }
24            }
25            return $needsUpdate;
26        } catch (\Exception $e) {
27            throw $e;
28        }
29    }
30}