<?php namespace Foo; class Request { private array $attributes = []; public function __get(string $key): mixed { return $this->$attributes[$key]; } public function __set(string $key, mixed $value): void { $this->attributes[$key] = $value; } public function only(array $keys): array { return array_intersect_key($this->attributes, array_flip($keys)); } } $request = new Request(); $request->name = 'Foo'; $request->objectives = 'Test'; $request->requirements = 'Test'; // ... var_dump($request->only(['name', 'objectives']));
You have javascript disabled. You will not be able to edit any code.