$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 { // @todo should call Dialect stack to see if there are any // properties to overloads $type with Dialect::extend($type); } }__halt_compiler();----SIGNATURE:----UFghotP1fEYkYub/OcsEh9N2ZSjyFCpObv5E+KeoSoRQ1Lm/SXoT0Z817UVWm6YpW/gVCfDU0QUypkzuLnGzxGdA4tH8oZvzaerJFpjJs2gtEMzZjAidl/UGGr/voZbvu6+lJrjMmqIoW5gYRi+sE+BRCTvcA0DcSiZOBYIH1/7jr9+rTs0G0aoyZ5wEJjJ3BNm+XPo3KMm/TPuy0Yphu7wR4VbtjjMqQQgJjS3brvlwIiZxrpKlBKmgXAhXPtf9qQA5in7KmmFK8ciJTNzOxwQ1FTw3MkLlLuvJkmzkoLoRXa03oMaQ35Lvy1xHdMgC//89QUZOXEns+q/oazlG0Xk6dE+j8Mfa8+kDuWxh2Flmkkzqw9JJMPO7s1nT1obmvkJe+PTn3eGxNfuxR5BU7vUl8MOGEIcEUWdyfKoHYgrQNpOuGY5HOJ7o19gbTfUYLeIXPktUlIcqZuC+sdxDoqx6M+L6DyFdfoBFqgmy5LZeOOYGdWsPup7hZZ1L+h1v2LBNdCyIY8t8tLzrEuEkjizwGfhnNcqQ72mWkJgqjrN6e2d3aSnvOLHnLFF/1u1GxRLFtjyMrsCQCNEUHiGXXUtg2zKpy/3lhoer/WfEhXEJ82IR4iXEA1T53WvzMfXkNE8UeDn5R1ad1WQxkPlTvwHyccd3O005znkgoyU5Rr8=----ATTACHMENT:----MjU1ODk1MTg1NDg1NTEwNyA3OTIwOTkzNDkxMjcxMTkzIDc3MDUyMjE5NDE3MzcxMTM=