diff --git a/root/Album.php b/root/Album.php index 5dc7271..7415f1c 100644 --- a/root/Album.php +++ b/root/Album.php @@ -38,10 +38,8 @@ class Album { $this->thumbnail = $root->{'thumbnail'}; $this->images = $root->{'images'}; if (property_exists($root, 'metadata')) { - $this->metadata = $root->{'metadata'}; - } else { - $this->metadata = null; - } + $this->metadata; + } } private function invalidate() { @@ -129,12 +127,27 @@ class Album { 'longitude' => '' ]; } - $description = $this->metadata->{$image}->{'description'}; - $date = $this->metadata->{$image}->{'date'}; - $time = $this->metadata->{$image}->{'time'}; - $lat= $this->metadata->{$image}->{'latitude'}; - $lon = $this->metadata->{$image}->{'longitude'}; - if (preg_match($this::NUMBER_REGEX, $lat) === false || preg_match($this::NUMBER_REGEX, $lon) === false) { + $description = null; + $date = null; + $time = null; + $lat = null; + $lon = null; + if (property_exists($this->metadata->{$image}, 'description')) { + $description = $this->metadata->{$image}?->{'description'}; + } + if (property_exists($this->metadata->{$image}, 'date')) { + $date = $this->metadata->{$image}?->{'date'}; + } + if (property_exists($this->metadata->{$image}, 'time')) { + $time = $this->metadata->{$image}?->{'time'}; + } + if (property_exists($this->metadata->{$image}, 'latitude')) { + $lat= $this->metadata->{$image}?->{'latitude'}; + } + if (property_exists($this->metadata->{$image}, 'longitude')) { + $lon = $this->metadata->{$image}?->{'longitude'}; + } + if ($lat && $lon && (preg_match($this::NUMBER_REGEX, $lat) === false || preg_match($this::NUMBER_REGEX, $lon) === false)) { $lat = null; $lon = null; }