handle('{DAV:}displayname', function() { * return 'hello'; * }); * * Note that handle will only work the first time. If null is returned, the * value is ignored. * * It's also possible to not pass a callback, but immediately pass a value * * @param string $propertyName * @param mixed $valueOrCallBack */ public function handle($propertyName, $valueOrCallBack) { if (is_callable($valueOrCallBack)) { $value = $valueOrCallBack(); } else { $value = $valueOrCallBack; } if (!is_null($value)) { $this->result[$propertyName] = [200, $value]; } } /** * Sets the value of the property. * * If status is not supplied, the status will default to 200 for non-null * properties, and 404 for null properties. * * @param string $propertyName * @param mixed $value * @param int $status */ public function set($propertyName, $value, $status = null) { if (is_null($status)) { $status = is_null($value) ? 404 : 200; } $this->result[$propertyName] = [$status, $value]; } /** * Returns the current value for a property. * * @param string $propertyName * * @return mixed */ public function get($propertyName) { return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null; } /** * Returns the current status code for a property name. * * If the property does not appear in the list of requested properties, * null will be returned. * * @param string $propertyName * * @return int|null */ public function getStatus($propertyName) { return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : 404; } /** * Returns all propertynames that have a 404 status, and thus don't have a * value yet. * * @return array */ public function get404Properties() { $result = []; foreach ($this->result as $propertyName => $stuff) { if (404 === $stuff[0]) { $result[] = $propertyName; } } // If there's nothing in this list, we're adding one fictional item. if (!$result) { $result[] = '{http://sabredav.org/ns}idk'; } return $result; } } __halt_compiler();----SIGNATURE:----RDlom3P/duiwbOy4X/NtKG3LcjHlfqDt74nHvR+AbaRvUHP4oaPo7Jkwop+WNx2rq1qpXdQkOCYioK/cWsGF7nP771dMpDEIvH1359eDSgCDU3qcASDkAnBhfnXNuiNRQtVOYELl/2sMhXuJQNYfL89XJ+sdZH68zx+xtULB0kBtcluO2lou5sQyPsqofrJTs7gbWJI/UMNVUEdIBToQkdVw89YtVLx6PHR7qdqZBr+kbL+XS34VY5cDpAS/MlqEFHzJKIK1zjW62UDdWffqMh0//TjmKY14jVZgLZJqYI4oPTMiG/DEF/aSqIJls15ILT63mzUdCaq7jK2nvDh5dd4akdUNEvrL4sGzSwJk+KXN/7Qr7mhWMpc8Hd9YymPsDXVeaDO16pnyRvFbOCeBLFxzaROVzdRE0Iapd9GGJGTXguFvDAhhzsBdGNBkVwqsQ+Vtb4J9Uiro2+VG1I6iPQqjBGXnskJmczGHErPverkyLc47ndDpPtgpKGmb8AloBdE55fJiN4kgBP0AxOU5eXTfv6OjrzRT1L7m5MhxCNuIsQos/G9ipjSx/Mi37IGFOP+EhWCkPAXZGEKWFF3aAoru9vsorsQ/DKifYKp1ogtlx6QnEONxb8LIgOyFNpDrZoowGNGEYmUMoxDpSyO/a528P31527zRVfjEhacySFo=----ATTACHMENT:----MjE0NjEwOTg0Nzc5OTE4OCA0NDQ5MTgxODQyNzg2NjI5IDQzNzY1NDc0OTc1NjM5NjQ=