filters[$type] = isset($this->filters[$type]) ? array_merge($this->filters[$type], [ $filter ]) : [ $filter ]; return $this; } // Clear all registered filters public function clearFilters() { $this->filters = []; return $this; } // Returns boolean whether the filterable passes all registered filters protected function passesFilters($args, $type = 'default') { $filters = isset($this->filters[$type]) ? $this->filters[$type] : []; foreach ($filters as $filter) { if (! $filter(...$args)) return false; } return true; } // Censors passwords in an array, identified by key containing "pass" substring public function removePasswords(array $data) { $keys = array_keys($data); $values = array_map(function ($value, $key) { return strpos($key, 'pass') !== false ? '*removed*' : $value; }, $data, $keys); return array_combine($keys, $values); } }