PluginProbe
ActivityPub / 7.8.4
ActivityPub v7.8.4
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / includes / transformer / class-json.php

class-json.php in ActivityPub 7.8.4, at includes/transformer/class-json.php

42 lines 844 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * String Transformer Class file.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\Transformer;
9
10 use function Activitypub\is_activity;
11 use function Activitypub\is_actor;
12
13 /**
14 * String Transformer Class file.
15 */
16 class Json extends Activity_Object {
17
18 /**
19 * JSON constructor.
20 *
21 * @param string|array $item The item that should be transformed.
22 */
23 public function __construct( $item ) {
24 if ( \is_string( $item ) ) {
25 $item = \json_decode( $item, true );
26 }
27
28 // Check if the item is an Activity or an Object.
29 if ( is_activity( $item ) ) {
30 $class = '\Activitypub\Activity\Activity';
31 } elseif ( is_actor( $item ) ) {
32 $class = '\Activitypub\Activity\Actor';
33 } else {
34 $class = '\Activitypub\Activity\Base_Object';
35 }
36
37 $object = $class::init_from_array( $item );
38
39 parent::__construct( $object );
40 }
41 }
42