/** * @param \XMLReader $xml * @return static */ public static function parseXml(\XMLReader $xml) { $self = new self(); $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?>' . $xml->readOuterXml()); foreach ($xml->attributes() as $attribute => $value) { $method = 'set' . $self->camelize($attribute); if (method_exists($self, $method)) { call_user_func([$self, $method], (string) $value); } } return $self; }