@@ -90,8 +90,7 @@ class ModelCache {
9090 * @param string $index_field The field name to index the Model objects by.
9191 * @return array An associative array of indexed Model objects.
9292 */
93- public static function index_modelset_by_field (string $ model_class , string $ index_field ): array
94- {
93+ public static function index_modelset_by_field (string $ model_class , string $ index_field ): array {
9594 # First, check if this Model class has already been indexed by this field
9695 if (isset (self ::$ index [$ model_class ][$ index_field ])) {
9796 return self ::$ index [$ model_class ][$ index_field ];
@@ -122,11 +121,7 @@ class ModelCache {
122121 * @param mixed $index_value The index field value to look up the Model object by
123122 * @return bool True if a cached Model object exists for the specified Model class and index
124123 */
125- public static function has_model (
126- string $ model_class ,
127- string $ index_field = 'id ' ,
128- mixed $ index_value = null ,
129- ): bool {
124+ public static function has_model (string $ model_class , string $ index_field = 'id ' , mixed $ index_value = null ): bool {
130125 # Cache is always a miss if the Model class is not indexed
131126 if (!self ::$ index [$ model_class ]) {
132127 return false ;
@@ -145,7 +140,7 @@ class ModelCache {
145140 * Caches a Model object in the ModelCache by its index field/value.
146141 * @param Model $model The Model object to cache.
147142 * @param string $index_field The field to index the Model object by. Only used for many enabled Models.
148- */
143+ */
149144 public static function cache_model (Model $ model , string $ index_field = 'id ' ): void {
150145 # Determine the Model class of the Model object
151146 $ model_class = $ model ->get_class_fqn ();
@@ -183,12 +178,11 @@ class ModelCache {
183178 string $ model_class ,
184179 string $ index_field = 'id ' ,
185180 mixed $ index_value = null ,
186- ): Model
187- {
181+ ): Model {
188182 if (!self ::has_model ($ model_class , $ index_field , $ index_value )) {
189183 throw new NotFoundError (
190184 message: "No cached Model found for Model class ' $ model_class' with " .
191- "index field ' $ index_field' and index value ' $ index_value'. " ,
185+ "index field ' $ index_field' and index value ' $ index_value'. " ,
192186 response_id: 'MODEL_CACHE_MODEL_NOT_FOUND ' ,
193187 );
194188 }
@@ -205,8 +199,7 @@ class ModelCache {
205199 /**
206200 * Clears the ModelCache of all cached ModelSets and indexed Model objects.
207201 */
208- public static function clear (): void
209- {
202+ public static function clear (): void {
210203 self ::$ index = [];
211204 self ::$ cache = [];
212205 }
0 commit comments