$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:----M97y9KDHpZ+OHNDCdr06g1hXi/f3EeZvYb0PnZGPkMQoe1d5L0i/ZKeUPJjGtvPLcLGWgpidG+5M+G49NNT02JmL9V0zgxtN3ymbZxKEAZjedOIDiGmCiuXzD6LvfYdPGNpq9IKxcBqVgYS7w/wgtaz6rPIWFC007cU544V/ATIPjuGt5kQJTVW4+1Ru+lZR4PgyAUlTJmtL91leRiH3D3YhfXyHq/1ytvJK04du5Pw0CQPhIB4VtFck1DVxHyvikH1kCMuTl80cK/nM9UNbICC01sv26sUqs+NI4d0ErjYh2zBqz0COZnCTXymxUTCsZ9FrI21v4Fq0mYgSAiJrRgNpDLRtppyqrmis6EoLmQm6eupFaf+tMk53Fpr7MJDNHYe/I4gWiFYg0/z3DAqkEoIbMinpo/FvZi5t3cAP8xfqizRKLi8SYfd/thfMIfE3QUuWIsnUlrTiMkAgclv9VqHGFou+79A/ULjQ4BXN9ah4XGCw3Sx927TsFRG3z4ZkOo2up4qftgSU/aQTndyLbRTPPRtG5bArfHkvgVjFZxhBryAjYVVmwvMaAnwB5JOUlc8NbjX+UM0JcUVTbf/7k6HRqTbRPpog0U5R7N4esJO54RN60TWxzjGms0NfVEyWJFTmGtl7kux7ES5KdNs71YqbckH0WJj+ujf3z7Jg0TQ=----ATTACHMENT:----MjA0ODc0ODI4NDgwNDk2OSA0ODMyNjcxMjM1MDQ2NjczIDkyNTA4Mzc5MjEyODM3Ng==