{$property} ?? null; } if (preg_match('/^set([a-z]+)/i', $name, $matches) && $arguments) { // setter method invoked $property = strtolower($matches[1]); if (property_exists($this, $property)) { // set the value for the requested property $this->{$property} = $arguments[0]; } // return self for chain-ability return $this; } throw new Exception(sprintf('Could not call device capability method %s.', $name), 500); } /** * Tells if the device capability provides parameters for its execution. * * @return bool */ public function providesParams() { return !empty($this->params); } /** * Tells if the device capability meets the minimum requirements. * * @return bool */ public function isValid() { return !empty($this->id) && !empty($this->title) && !empty($this->callback); } /** * Executes the capability through the callback instructions, if set. * * @param VBODooraccessIntegrationAware $integration The provider integration object. * @param VBODooraccessIntegrationDevice $device The device executing the capability. * @param ?array $options Optional settings obtained from the params. * * @return ?string Optional execution result string to display. * * @throws Exception */ public function execute(VBODooraccessIntegrationAware $integration, VBODooraccessIntegrationDevice $device, ?array $options = null) { if (!is_string($this->callback) || !is_callable([$integration, $this->callback])) { throw new Exception('Could not execute device capability.', 500); } // execute the capability on the provider integration object return call_user_func_array([$integration, $this->callback], [$device, $options]); } }