1<?php 2 3 4namespace ComboStrap; 5 6 7abstract class ResourceComboAbs implements ResourceCombo 8{ 9 10 11 /** 12 * @var Metadata 13 */ 14 private $uidObject; 15 16 public function exists(): bool 17 { 18 return FileSystems::exists($this->getPath()); 19 } 20 21 /** 22 * A buster cache 23 * @return string 24 */ 25 public function getBuster(): string 26 { 27 $time = FileSystems::getModifiedTime($this->getPath()); 28 return strval($time->getTimestamp()); 29 } 30 31 /** 32 * An utility function that {@link MetadataStore::persist() persists} the value 33 * into the default {@link ResourceCombo::getReadStoreOrDefault()} 34 * @return $this 35 */ 36 public function persist(): ResourceComboAbs 37 { 38 $this->getReadStoreOrDefault()->persist(); 39 return $this; 40 } 41 42 public function getUidObject() 43 { 44 if ($this->uidObject === null) { 45 $this->uidObject = Metadata::toMetadataObject($this->getUid()) 46 ->setResource($this); 47 } 48 49 return $this->uidObject; 50 51 } 52 53 54} 55