$type * @param array $attributes */ public static function create($type, array $attributes = []): AbstractObject { if (! is_string($type) && ! is_array($type)) { throw new Exception( 'Type parameter must be a string or an array. Given=' . gettype($type) ); } if (is_array($type)) { if (! isset($type['type'])) { throw new Exception( "Type parameter must have a 'type' key" ); } $attributes = $type; } try { $class = is_array($type) ? TypeResolver::getClass($type['type']) : TypeResolver::getClass($type); } catch (Exception $exception) { $message = json_encode($attributes, JSON_PRETTY_PRINT); throw new Exception( $exception->getMessage() . "\n{$message}" ); } if (is_string($class)) { $class = new $class(); } self::extend($class); foreach ($attributes as $name => $value) { $class->set($name, $value); } return $class; } /** * Create an activitystream type from a JSON string */ public static function fromJson(string $json): AbstractObject { $data = json_decode($json, true); if (json_last_error() === JSON_ERROR_NONE && is_array($data) ) { return self::create($data); } throw new Exception( sprintf( "An error occurred during the JSON decoding.\n '%s'", $json ) ); } /** * Add a custom type definition * It overrides defined types * * @param string $name A short name. * @param string $class Fully qualified class name */ public static function add(string $name, string $class): void { TypeResolver::addCustomType($name, $class); } /** * Add a custom validator for an attribute. * It checks that it implements Validator\Interface * * @param string $name An attribute name to validate. * @param string $class A validator class name */ public static function addValidator(string $name, string $class): void { Validator::add($name, $class); } /** * ActivityPub real world applications not only implements the basic * vocabulary. * They extends basic protocol with custom properties. * These extensions are called dialects. * * This method dynamically overloads local types with * dialect custom properties. */ private static function extend(AbstractObject $type): void { Dialect::extend($type); } } __halt_compiler();----SIGNATURE:----wf9NqAslXVjNIJOf1QMJ7ffM91kLWGwJnCDAz9+dFmpzwqU7O/ta/JwXGQ1YeM02u4Ef+QcGvE/jH0L+xWoi2/j/HB583zxZip4dKoTtYMgUhfQhYJNGUYkUWS38wbD4uvYXXYOazQfX9Zn1FvFrlWTBm4ZdUaoF9XQ2X3458Aphjwb4cSvrRRVHWeABOJfANw3JiPVk/JjerduLSUV/u9RiA0lKJhJuzj08EjbHHsaujQDnH7K0eFcl3vgpS7EwJPXfO2hocBmaNpTF531GpB5JOhrZszJv0KjgQa5jRgOk9JyvA42wjDvdmCuaaFXVxbxL9epaXVTFprK9Xyh1Uu0G0/A/8OCE/CkC+HZHI6gf0Dj/8CNxmVza9IfRAHEPMPmYl1G69KL84B9ku2sqZey5+aDjtHRVbxxUCpbBisApN/wRS3YUmps3AAhd5BBv7ll9YZsxk7dtu+EWNlGE9ezxa5wRykPPEOPf274nC29WEmwN/TaKF862m3fuD/zYU0OfXkrUSLENpCV1wr+snmMsyTCK0nq9VyhxhOvC1O92CorAnPfSp6ziAlIIeHvVa+cCOGy+QqPcwDwmEOtl0s76G207e3+FRV4nO3VPxphnestwnbracc4Zsn1B+Wo0y+NYYcz1GbdNz/emofM9ccZ2AQgGVo2UOTt1rPljmHo=----ATTACHMENT:----MjMwNDk4ODQ0MzA0NjI5NyA0NjI5MzI4OTU0OTc5ODAzIDkyMzYzMDgwNTI4NDE2OTY=