Completed
Branch FET/reg-form-builder/main (0f11d8)
by
unknown
02:56 queued 17s
created
core/domain/services/graphql/mutators/FormElementCreate.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -12,51 +12,51 @@
 block discarded – undo
12 12
 class FormElementCreate extends EntityMutator
13 13
 {
14 14
 
15
-    /**
16
-     * Defines the mutation data modification closure.
17
-     *
18
-     * @param EEM_Form_Element $model
19
-     * @return callable
20
-     */
21
-    public static function mutateAndGetPayload(EEM_Form_Element $model)
22
-    {
23
-        /**
24
-         * Creates an entity.
25
-         *
26
-         * @param array       $input   The input for the mutation
27
-         * @param AppContext  $context The AppContext passed down to all resolvers
28
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
29
-         * @return array
30
-         */
31
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
32
-            $id = null;
33
-            try {
34
-                EntityMutator::checkPermissions($model);
35
-
36
-                $args = FormElementMutation::prepareFields($input);
37
-
38
-                $entity = EE_Form_Element::new_instance($args);
39
-                $id = $entity->save();
40
-                EntityMutator::validateResults($id);
41
-
42
-                do_action(
43
-                    'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_element_create',
44
-                    $entity,
45
-                    $input
46
-                );
47
-            } catch (Exception $exception) {
48
-                EntityMutator::handleExceptions(
49
-                    $exception,
50
-                    esc_html__(
51
-                        'The form element could not be created because of the following error(s)',
52
-                        'event_espresso'
53
-                    )
54
-                );
55
-            }
56
-
57
-            return [
58
-                'id' => $id,
59
-            ];
60
-        };
61
-    }
15
+	/**
16
+	 * Defines the mutation data modification closure.
17
+	 *
18
+	 * @param EEM_Form_Element $model
19
+	 * @return callable
20
+	 */
21
+	public static function mutateAndGetPayload(EEM_Form_Element $model)
22
+	{
23
+		/**
24
+		 * Creates an entity.
25
+		 *
26
+		 * @param array       $input   The input for the mutation
27
+		 * @param AppContext  $context The AppContext passed down to all resolvers
28
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
29
+		 * @return array
30
+		 */
31
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
32
+			$id = null;
33
+			try {
34
+				EntityMutator::checkPermissions($model);
35
+
36
+				$args = FormElementMutation::prepareFields($input);
37
+
38
+				$entity = EE_Form_Element::new_instance($args);
39
+				$id = $entity->save();
40
+				EntityMutator::validateResults($id);
41
+
42
+				do_action(
43
+					'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_element_create',
44
+					$entity,
45
+					$input
46
+				);
47
+			} catch (Exception $exception) {
48
+				EntityMutator::handleExceptions(
49
+					$exception,
50
+					esc_html__(
51
+						'The form element could not be created because of the following error(s)',
52
+						'event_espresso'
53
+					)
54
+				);
55
+			}
56
+
57
+			return [
58
+				'id' => $id,
59
+			];
60
+		};
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
30 30
          * @return array
31 31
          */
32
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
32
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array {
33 33
             $id = null;
34 34
             try {
35 35
                 EntityMutator::checkPermissions($model);
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/FormElementUpdate.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -14,52 +14,52 @@
 block discarded – undo
14 14
 class FormElementUpdate extends EntityMutator
15 15
 {
16 16
 
17
-    /**
18
-     * Defines the mutation data modification closure.
19
-     *
20
-     * @param EEM_Form_Element $model
21
-     * @return callable
22
-     */
23
-    public static function mutateAndGetPayload(EEM_Form_Element $model)
24
-    {
25
-        /**
26
-         * Updates an entity.
27
-         *
28
-         * @param array       $input   The input for the mutation
29
-         * @param AppContext  $context The AppContext passed down to all resolvers
30
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31
-         * @return array
32
-         * @throws EE_Error
33
-         * @throws ReflectionException
34
-         */
35
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
36
-            try {
37
-                /** @var EE_Form_Element $entity */
38
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
17
+	/**
18
+	 * Defines the mutation data modification closure.
19
+	 *
20
+	 * @param EEM_Form_Element $model
21
+	 * @return callable
22
+	 */
23
+	public static function mutateAndGetPayload(EEM_Form_Element $model)
24
+	{
25
+		/**
26
+		 * Updates an entity.
27
+		 *
28
+		 * @param array       $input   The input for the mutation
29
+		 * @param AppContext  $context The AppContext passed down to all resolvers
30
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31
+		 * @return array
32
+		 * @throws EE_Error
33
+		 * @throws ReflectionException
34
+		 */
35
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
36
+			try {
37
+				/** @var EE_Form_Element $entity */
38
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
39 39
 
40
-                $args = FormElementMutation::prepareFields($input);
40
+				$args = FormElementMutation::prepareFields($input);
41 41
 
42
-                // Update the entity
43
-                $entity->save($args);
42
+				// Update the entity
43
+				$entity->save($args);
44 44
 
45
-                do_action(
46
-                    'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_element_update',
47
-                    $entity,
48
-                    $input
49
-                );
50
-            } catch (Exception $exception) {
51
-                EntityMutator::handleExceptions(
52
-                    $exception,
53
-                    esc_html__(
54
-                        'The form element could not be updated because of the following error(s)',
55
-                        'event_espresso'
56
-                    )
57
-                );
58
-            }
45
+				do_action(
46
+					'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_element_update',
47
+					$entity,
48
+					$input
49
+				);
50
+			} catch (Exception $exception) {
51
+				EntityMutator::handleExceptions(
52
+					$exception,
53
+					esc_html__(
54
+						'The form element could not be updated because of the following error(s)',
55
+						'event_espresso'
56
+					)
57
+				);
58
+			}
59 59
 
60
-            return [
61
-                'id' => $entity->UUID(),
62
-            ];
63
-        };
64
-    }
60
+			return [
61
+				'id' => $entity->UUID(),
62
+			];
63
+		};
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
          * @throws EE_Error
33 33
          * @throws ReflectionException
34 34
          */
35
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
35
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array {
36 36
             try {
37 37
                 /** @var EE_Form_Element $entity */
38 38
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/FormSectionMutation.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
             $args['FSC_status'] = sanitize_text_field($input['status']);
50 50
         }
51 51
 
52
-        if (! empty($input['wpUser'])) {
52
+        if ( ! empty($input['wpUser'])) {
53 53
             $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
54 54
             $args['FSC_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null;
55 55
         }
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,54 +15,54 @@
 block discarded – undo
15 15
 class FormSectionMutation
16 16
 {
17 17
 
18
-    /**
19
-     * Maps the GraphQL input to a format that the model functions can use
20
-     *
21
-     * @param array $input Data coming from the GraphQL mutation query input
22
-     * @return array
23
-     */
24
-    public static function prepareFields(array $input): array
25
-    {
26
-        $args = [];
18
+	/**
19
+	 * Maps the GraphQL input to a format that the model functions can use
20
+	 *
21
+	 * @param array $input Data coming from the GraphQL mutation query input
22
+	 * @return array
23
+	 */
24
+	public static function prepareFields(array $input): array
25
+	{
26
+		$args = [];
27 27
 
28
-        if (isset($input['id'])) {
29
-            $args['FSC_UUID'] = sanitize_text_field($input['id']);
30
-        }
28
+		if (isset($input['id'])) {
29
+			$args['FSC_UUID'] = sanitize_text_field($input['id']);
30
+		}
31 31
 
32
-        if (isset($input['appliesTo'])) {
33
-            $args['FSC_appliesTo'] = sanitize_text_field($input['appliesTo']);
34
-        }
32
+		if (isset($input['appliesTo'])) {
33
+			$args['FSC_appliesTo'] = sanitize_text_field($input['appliesTo']);
34
+		}
35 35
 
36
-        if (isset($input['attributes'])) {
37
-            $args['FSC_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson();
38
-        }
36
+		if (isset($input['attributes'])) {
37
+			$args['FSC_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson();
38
+		}
39 39
 
40
-        if (isset($input['belongsTo'])) {
41
-            $args['FSC_belongsTo'] = sanitize_text_field($input['belongsTo']);
42
-        }
40
+		if (isset($input['belongsTo'])) {
41
+			$args['FSC_belongsTo'] = sanitize_text_field($input['belongsTo']);
42
+		}
43 43
 
44
-        if (isset($input['label'])) {
45
-            $args['FSC_label'] = FormLabel::fromJson(sanitize_text_field($input['label']))->toJson();
46
-        }
44
+		if (isset($input['label'])) {
45
+			$args['FSC_label'] = FormLabel::fromJson(sanitize_text_field($input['label']))->toJson();
46
+		}
47 47
 
48
-        // order can be 0
49
-        if (array_key_exists('order', $input)) {
50
-            $args['FSC_order'] = absint($input['order']);
51
-        }
48
+		// order can be 0
49
+		if (array_key_exists('order', $input)) {
50
+			$args['FSC_order'] = absint($input['order']);
51
+		}
52 52
 
53
-        if (isset($input['status'])) {
54
-            $args['FSC_status'] = sanitize_text_field($input['status']);
55
-        }
53
+		if (isset($input['status'])) {
54
+			$args['FSC_status'] = sanitize_text_field($input['status']);
55
+		}
56 56
 
57
-        if (! empty($input['wpUser'])) {
58
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
59
-            $args['FSC_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null;
60
-        }
57
+		if (! empty($input['wpUser'])) {
58
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
59
+			$args['FSC_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null;
60
+		}
61 61
 
62
-        return apply_filters(
63
-            'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_section_args',
64
-            $args,
65
-            $input
66
-        );
67
-    }
62
+		return apply_filters(
63
+			'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_section_args',
64
+			$args,
65
+			$input
66
+		);
67
+	}
68 68
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/FormElementLoader.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class FormElementLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Form_Element::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Form_Element::instance();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $keys
33
-     * @return array
34
-     */
35
-    protected function getWhereParams(array $keys): array
36
-    {
37
-        return [
38
-            'FIN_UUID' => ['IN', $keys],
39
-        ];
40
-    }
31
+	/**
32
+	 * @param array $keys
33
+	 * @return array
34
+	 */
35
+	protected function getWhereParams(array $keys): array
36
+	{
37
+		return [
38
+			'FIN_UUID' => ['IN', $keys],
39
+		];
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/abstracts/AbstractRootQueryConnection.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,28 +19,28 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * @param $entity
24
-     * @param $args
25
-     * @param $context
26
-     * @param $info
27
-     * @return AbstractConnectionResolver
28
-     * @throws Exception
29
-     */
30
-    abstract public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver;
22
+	/**
23
+	 * @param $entity
24
+	 * @param $args
25
+	 * @param $context
26
+	 * @param $info
27
+	 * @return AbstractConnectionResolver
28
+	 * @throws Exception
29
+	 */
30
+	abstract public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver;
31 31
 
32 32
 
33
-    /**
34
-     * @param $entity
35
-     * @param $args
36
-     * @param $context
37
-     * @param $info
38
-     * @return mixed|array|Deferred
39
-     * @throws Exception
40
-     */
41
-    public function resolveConnection($entity, $args, $context, $info)
42
-    {
43
-        $resolver = $this->getConnectionResolver($entity, $args, $context, $info);
44
-        return $resolver->get_connection();
45
-    }
33
+	/**
34
+	 * @param $entity
35
+	 * @param $args
36
+	 * @param $context
37
+	 * @param $info
38
+	 * @return mixed|array|Deferred
39
+	 * @throws Exception
40
+	 */
41
+	public function resolveConnection($entity, $args, $context, $info)
42
+	{
43
+		$resolver = $this->getConnectionResolver($entity, $args, $context, $info);
44
+		return $resolver->get_connection();
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/shared/GQLRequests.php 1 patch
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -19,223 +19,223 @@
 block discarded – undo
19 19
  */
20 20
 class GQLRequests extends Route
21 21
 {
22
-    /**
23
-     * @var AssetManifestFactory
24
-     */
25
-    private $manifest_factory;
22
+	/**
23
+	 * @var AssetManifestFactory
24
+	 */
25
+	private $manifest_factory;
26 26
 
27 27
 
28
-    /**
29
-     * AssetRequests constructor.
30
-     *
31
-     * @param EE_Dependency_Map    $dependency_map
32
-     * @param LoaderInterface      $loader
33
-     * @param RequestInterface     $request
34
-     * @param AssetManifestFactory $manifest_factory
35
-     */
36
-    public function __construct(
37
-        EE_Dependency_Map $dependency_map,
38
-        LoaderInterface $loader,
39
-        RequestInterface $request,
40
-        AssetManifestFactory $manifest_factory
41
-    ) {
42
-        $this->manifest_factory = $manifest_factory;
43
-        parent::__construct($dependency_map, $loader, $request);
44
-    }
28
+	/**
29
+	 * AssetRequests constructor.
30
+	 *
31
+	 * @param EE_Dependency_Map    $dependency_map
32
+	 * @param LoaderInterface      $loader
33
+	 * @param RequestInterface     $request
34
+	 * @param AssetManifestFactory $manifest_factory
35
+	 */
36
+	public function __construct(
37
+		EE_Dependency_Map $dependency_map,
38
+		LoaderInterface $loader,
39
+		RequestInterface $request,
40
+		AssetManifestFactory $manifest_factory
41
+	) {
42
+		$this->manifest_factory = $manifest_factory;
43
+		parent::__construct($dependency_map, $loader, $request);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * returns true if the current request matches this route
49
-     *
50
-     * @return bool
51
-     * @since   $VID:$
52
-     */
53
-    public function matchesCurrentRequest(): bool
54
-    {
55
-        global $pagenow;
56
-        return (
57
-                   $this->request->isGQL()
58
-                   || $this->request->isUnitTesting()
59
-                   || (
60
-                       $this->request->isAdmin()
61
-                       && $this->request->getRequestParam('page') === 'espresso_events'
62
-                       && (
63
-                           $this->request->getRequestParam('action') === 'create_new'
64
-                           || $this->request->getRequestParam('action') === 'edit'
65
-                       )
66
-                   )
67
-                   || (
68
-                       $pagenow
69
-                       && (
70
-                           $pagenow === 'post-new.php'
71
-                           || (
72
-                               $pagenow === 'post.php'
73
-                               && $this->request->getRequestParam('action') === 'edit'
74
-                           )
75
-                       )
76
-                   )
77
-               );
78
-    }
47
+	/**
48
+	 * returns true if the current request matches this route
49
+	 *
50
+	 * @return bool
51
+	 * @since   $VID:$
52
+	 */
53
+	public function matchesCurrentRequest(): bool
54
+	{
55
+		global $pagenow;
56
+		return (
57
+				   $this->request->isGQL()
58
+				   || $this->request->isUnitTesting()
59
+				   || (
60
+					   $this->request->isAdmin()
61
+					   && $this->request->getRequestParam('page') === 'espresso_events'
62
+					   && (
63
+						   $this->request->getRequestParam('action') === 'create_new'
64
+						   || $this->request->getRequestParam('action') === 'edit'
65
+					   )
66
+				   )
67
+				   || (
68
+					   $pagenow
69
+					   && (
70
+						   $pagenow === 'post-new.php'
71
+						   || (
72
+							   $pagenow === 'post.php'
73
+							   && $this->request->getRequestParam('action') === 'edit'
74
+						   )
75
+					   )
76
+				   )
77
+			   );
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * @since $VID:$
83
-     */
84
-    protected function registerDependencies()
85
-    {
86
-        $this->dependency_map->registerDependencies(
87
-            'EventEspresso\core\services\graphql\GraphQLManager',
88
-            [
89
-                'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache,
90
-                'EventEspresso\core\services\graphql\DataLoaderManager'  => EE_Dependency_Map::load_from_cache,
91
-                'EventEspresso\core\services\graphql\EnumsManager'       => EE_Dependency_Map::load_from_cache,
92
-                'EventEspresso\core\services\graphql\InputsManager'      => EE_Dependency_Map::load_from_cache,
93
-                'EventEspresso\core\services\graphql\TypesManager'       => EE_Dependency_Map::load_from_cache,
94
-            ]
95
-        );
96
-        $this->dependency_map->registerDependencies(
97
-            'EventEspresso\core\services\graphql\TypesManager',
98
-            [
99
-                'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
100
-            ]
101
-        );
102
-        $this->dependency_map->registerDependencies(
103
-            'EventEspresso\core\services\graphql\InputsManager',
104
-            [
105
-                'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
106
-            ]
107
-        );
108
-        $this->dependency_map->registerDependencies(
109
-            'EventEspresso\core\services\graphql\EnumsManager',
110
-            [
111
-                'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
112
-            ]
113
-        );
114
-        $this->dependency_map->registerDependencies(
115
-            'EventEspresso\core\services\graphql\ConnectionsManager',
116
-            [
117
-                'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
118
-            ]
119
-        );
120
-        $this->dependency_map->registerDependencies(
121
-            'EventEspresso\core\services\graphql\DataLoaderManager',
122
-            [
123
-                'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache,
124
-            ]
125
-        );
126
-        $this->dependency_map->registerDependencies(
127
-            'EventEspresso\core\domain\services\graphql\types\Datetime',
128
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
129
-        );
130
-        $this->dependency_map->registerDependencies(
131
-            'EventEspresso\core\domain\services\graphql\types\Attendee',
132
-            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
133
-        );
134
-        $this->dependency_map->registerDependencies(
135
-            'EventEspresso\core\domain\services\graphql\types\Event',
136
-            ['EEM_Event' => EE_Dependency_Map::load_from_cache]
137
-        );
138
-        $this->dependency_map->registerDependencies(
139
-            'EventEspresso\core\domain\services\graphql\types\FormElement',
140
-            ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
141
-        );
142
-        $this->dependency_map->registerDependencies(
143
-            'EventEspresso\core\domain\services\graphql\types\FormSection',
144
-            ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
145
-        );
146
-        $this->dependency_map->registerDependencies(
147
-            'EventEspresso\core\domain\services\graphql\types\Ticket',
148
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
149
-        );
150
-        $this->dependency_map->registerDependencies(
151
-            'EventEspresso\core\domain\services\graphql\types\Price',
152
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
153
-        );
154
-        $this->dependency_map->registerDependencies(
155
-            'EventEspresso\core\domain\services\graphql\types\PriceType',
156
-            ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
157
-        );
158
-        $this->dependency_map->registerDependencies(
159
-            'EventEspresso\core\domain\services\graphql\types\Venue',
160
-            ['EEM_Venue' => EE_Dependency_Map::load_from_cache]
161
-        );
162
-        $this->dependency_map->registerDependencies(
163
-            'EventEspresso\core\domain\services\graphql\types\State',
164
-            ['EEM_State' => EE_Dependency_Map::load_from_cache]
165
-        );
166
-        $this->dependency_map->registerDependencies(
167
-            'EventEspresso\core\domain\services\graphql\types\Country',
168
-            ['EEM_Country' => EE_Dependency_Map::load_from_cache]
169
-        );
170
-        $this->dependency_map->registerDependencies(
171
-            'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection',
172
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
173
-        );
174
-        $this->dependency_map->registerDependencies(
175
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection',
176
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
177
-        );
178
-        $this->dependency_map->registerDependencies(
179
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection',
180
-            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
181
-        );
182
-        $this->dependency_map->registerDependencies(
183
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection',
184
-            ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
185
-        );
186
-        $this->dependency_map->registerDependencies(
187
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection',
188
-            ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
189
-        );
190
-        $this->dependency_map->registerDependencies(
191
-            'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection',
192
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
193
-        );
194
-        $this->dependency_map->registerDependencies(
195
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection',
196
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
197
-        );
198
-        $this->dependency_map->registerDependencies(
199
-            'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection',
200
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
201
-        );
202
-        $this->dependency_map->registerDependencies(
203
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection',
204
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
205
-        );
206
-        $this->dependency_map->registerDependencies(
207
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection',
208
-            ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
209
-        );
210
-        $this->dependency_map->registerDependencies(
211
-            'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection',
212
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
213
-        );
214
-        $this->dependency_map->registerDependencies(
215
-            'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection',
216
-            ['EEM_Venue' => EE_Dependency_Map::load_from_cache]
217
-        );
218
-    }
81
+	/**
82
+	 * @since $VID:$
83
+	 */
84
+	protected function registerDependencies()
85
+	{
86
+		$this->dependency_map->registerDependencies(
87
+			'EventEspresso\core\services\graphql\GraphQLManager',
88
+			[
89
+				'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache,
90
+				'EventEspresso\core\services\graphql\DataLoaderManager'  => EE_Dependency_Map::load_from_cache,
91
+				'EventEspresso\core\services\graphql\EnumsManager'       => EE_Dependency_Map::load_from_cache,
92
+				'EventEspresso\core\services\graphql\InputsManager'      => EE_Dependency_Map::load_from_cache,
93
+				'EventEspresso\core\services\graphql\TypesManager'       => EE_Dependency_Map::load_from_cache,
94
+			]
95
+		);
96
+		$this->dependency_map->registerDependencies(
97
+			'EventEspresso\core\services\graphql\TypesManager',
98
+			[
99
+				'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
100
+			]
101
+		);
102
+		$this->dependency_map->registerDependencies(
103
+			'EventEspresso\core\services\graphql\InputsManager',
104
+			[
105
+				'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
106
+			]
107
+		);
108
+		$this->dependency_map->registerDependencies(
109
+			'EventEspresso\core\services\graphql\EnumsManager',
110
+			[
111
+				'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
112
+			]
113
+		);
114
+		$this->dependency_map->registerDependencies(
115
+			'EventEspresso\core\services\graphql\ConnectionsManager',
116
+			[
117
+				'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
118
+			]
119
+		);
120
+		$this->dependency_map->registerDependencies(
121
+			'EventEspresso\core\services\graphql\DataLoaderManager',
122
+			[
123
+				'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache,
124
+			]
125
+		);
126
+		$this->dependency_map->registerDependencies(
127
+			'EventEspresso\core\domain\services\graphql\types\Datetime',
128
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
129
+		);
130
+		$this->dependency_map->registerDependencies(
131
+			'EventEspresso\core\domain\services\graphql\types\Attendee',
132
+			['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
133
+		);
134
+		$this->dependency_map->registerDependencies(
135
+			'EventEspresso\core\domain\services\graphql\types\Event',
136
+			['EEM_Event' => EE_Dependency_Map::load_from_cache]
137
+		);
138
+		$this->dependency_map->registerDependencies(
139
+			'EventEspresso\core\domain\services\graphql\types\FormElement',
140
+			['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
141
+		);
142
+		$this->dependency_map->registerDependencies(
143
+			'EventEspresso\core\domain\services\graphql\types\FormSection',
144
+			['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
145
+		);
146
+		$this->dependency_map->registerDependencies(
147
+			'EventEspresso\core\domain\services\graphql\types\Ticket',
148
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
149
+		);
150
+		$this->dependency_map->registerDependencies(
151
+			'EventEspresso\core\domain\services\graphql\types\Price',
152
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
153
+		);
154
+		$this->dependency_map->registerDependencies(
155
+			'EventEspresso\core\domain\services\graphql\types\PriceType',
156
+			['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
157
+		);
158
+		$this->dependency_map->registerDependencies(
159
+			'EventEspresso\core\domain\services\graphql\types\Venue',
160
+			['EEM_Venue' => EE_Dependency_Map::load_from_cache]
161
+		);
162
+		$this->dependency_map->registerDependencies(
163
+			'EventEspresso\core\domain\services\graphql\types\State',
164
+			['EEM_State' => EE_Dependency_Map::load_from_cache]
165
+		);
166
+		$this->dependency_map->registerDependencies(
167
+			'EventEspresso\core\domain\services\graphql\types\Country',
168
+			['EEM_Country' => EE_Dependency_Map::load_from_cache]
169
+		);
170
+		$this->dependency_map->registerDependencies(
171
+			'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection',
172
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
173
+		);
174
+		$this->dependency_map->registerDependencies(
175
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection',
176
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
177
+		);
178
+		$this->dependency_map->registerDependencies(
179
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection',
180
+			['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
181
+		);
182
+		$this->dependency_map->registerDependencies(
183
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection',
184
+			['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
185
+		);
186
+		$this->dependency_map->registerDependencies(
187
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection',
188
+			['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
189
+		);
190
+		$this->dependency_map->registerDependencies(
191
+			'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection',
192
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
193
+		);
194
+		$this->dependency_map->registerDependencies(
195
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection',
196
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
197
+		);
198
+		$this->dependency_map->registerDependencies(
199
+			'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection',
200
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
201
+		);
202
+		$this->dependency_map->registerDependencies(
203
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection',
204
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
205
+		);
206
+		$this->dependency_map->registerDependencies(
207
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection',
208
+			['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
209
+		);
210
+		$this->dependency_map->registerDependencies(
211
+			'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection',
212
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
213
+		);
214
+		$this->dependency_map->registerDependencies(
215
+			'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection',
216
+			['EEM_Venue' => EE_Dependency_Map::load_from_cache]
217
+		);
218
+	}
219 219
 
220 220
 
221
-    /**
222
-     * implements logic required to run during request
223
-     *
224
-     * @return bool
225
-     * @since   $VID:$
226
-     */
227
-    protected function requestHandler(): bool
228
-    {
229
-        if (! class_exists('WPGraphQL')) {
230
-            require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
231
-        }
232
-        // load handler for EE GraphQL requests
233
-        $graphQL_manager = $this->loader->getShared(
234
-            'EventEspresso\core\services\graphql\GraphQLManager'
235
-        );
236
-        $graphQL_manager->init();
237
-        $manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain());
238
-        $manifest->initialize();
239
-        return true;
240
-    }
221
+	/**
222
+	 * implements logic required to run during request
223
+	 *
224
+	 * @return bool
225
+	 * @since   $VID:$
226
+	 */
227
+	protected function requestHandler(): bool
228
+	{
229
+		if (! class_exists('WPGraphQL')) {
230
+			require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
231
+		}
232
+		// load handler for EE GraphQL requests
233
+		$graphQL_manager = $this->loader->getShared(
234
+			'EventEspresso\core\services\graphql\GraphQLManager'
235
+		);
236
+		$graphQL_manager->init();
237
+		$manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain());
238
+		$manifest->initialize();
239
+		return true;
240
+	}
241 241
 }
Please login to merge, or discard this patch.
core/services/graphql/Utils.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@
 block discarded – undo
13 13
 class Utils
14 14
 {
15 15
 
16
-    /**
17
-     * Given a string, formats it as GraphQL ENUM value
18
-     *
19
-     * @param string $str The string to format
20
-     *
21
-     * @return string
22
-     */
23
-    public static function formatEnumKey($str)
24
-    {
25
-        // Replace any non-alph-anumeric by underscore
26
-        $str = preg_replace('/[^a-zA-Z0-9]/', '_', $str);
27
-        // Convert to uppercase.
28
-        return strtoupper($str);
29
-    }
16
+	/**
17
+	 * Given a string, formats it as GraphQL ENUM value
18
+	 *
19
+	 * @param string $str The string to format
20
+	 *
21
+	 * @return string
22
+	 */
23
+	public static function formatEnumKey($str)
24
+	{
25
+		// Replace any non-alph-anumeric by underscore
26
+		$str = preg_replace('/[^a-zA-Z0-9]/', '_', $str);
27
+		// Convert to uppercase.
28
+		return strtoupper($str);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
core/services/graphql/types/TypeBase.php 1 patch
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -35,270 +35,270 @@
 block discarded – undo
35 35
 abstract class TypeBase implements TypeInterface
36 36
 {
37 37
 
38
-    /**
39
-     * @var string $namespace The graphql namespace/prefix.
40
-     */
41
-    protected $namespace = 'Espresso';
42
-
43
-    /**
44
-     * @var EEM_Base $model
45
-     */
46
-    protected $model;
47
-
48
-    /**
49
-     * @var string $name
50
-     */
51
-    protected $name = '';
52
-
53
-    /**
54
-     * @var string $description
55
-     */
56
-    protected $description = '';
57
-
58
-    /**
59
-     * @var GraphQLFieldInterface[] $fields
60
-     */
61
-    protected $fields = [];
62
-
63
-    /**
64
-     * @var array $graphql_to_model_map
65
-     */
66
-    protected $graphql_to_model_map = [];
67
-
68
-    /**
69
-     * @var FieldResolver $field_resolver
70
-     */
71
-    protected $field_resolver;
72
-
73
-    /**
74
-     * @var bool $is_custom_post_type
75
-     */
76
-    protected $is_custom_post_type = false;
77
-
78
-
79
-    /**
80
-     * TypeBase constructor.
81
-     *
82
-     * @param EEM_Base|null $model
83
-     */
84
-    public function __construct(EEM_Base $model = null)
85
-    {
86
-        $this->model = $model;
87
-        $this->setFields($this->getFields());
88
-        $this->field_resolver = new FieldResolver(
89
-            $this->model,
90
-            $this->getFieldsForResolver()
91
-        );
92
-    }
93
-
94
-
95
-    /**
96
-     * @return GraphQLFieldInterface[]
97
-     * @since $VID:$
98
-     */
99
-    abstract protected function getFields(): array;
100
-
101
-
102
-    /**
103
-     * @return string
104
-     */
105
-    public function name(): string
106
-    {
107
-        return $this->name;
108
-    }
109
-
110
-
111
-    /**
112
-     * @param string $name
113
-     */
114
-    protected function setName(string $name)
115
-    {
116
-        $this->name = $name;
117
-    }
118
-
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public function description(): string
124
-    {
125
-        return $this->description;
126
-    }
127
-
128
-
129
-    /**
130
-     * @param string $description
131
-     */
132
-    protected function setDescription(string $description)
133
-    {
134
-        $this->description = $description;
135
-    }
136
-
137
-
138
-    /**
139
-     * @return GraphQLFieldInterface[]
140
-     * @since $VID:$
141
-     */
142
-    public function fields(): array
143
-    {
144
-        return (array) $this->fields;
145
-    }
146
-
147
-
148
-    /**
149
-     * @param GraphQLFieldInterface[] $fields
150
-     */
151
-    protected function setFields(array $fields)
152
-    {
153
-        foreach ($fields as $field) {
154
-            if ($field instanceof GraphQLField) {
155
-                $this->fields[] = $field;
156
-            }
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * Creates a key map for internal resolver.
163
-     *
164
-     * @return array
165
-     * @since $VID:$
166
-     */
167
-    public function getFieldsForResolver(): array
168
-    {
169
-        $fields = [];
170
-        foreach ($this->fields() as $field) {
171
-            if ($field->useForOutput()) {
172
-                $fields[ $field->name() ] = $field;
173
-            }
174
-        }
175
-        return $fields;
176
-    }
177
-
178
-
179
-    /**
180
-     * @return bool
181
-     */
182
-    public function isCustomPostType(): bool
183
-    {
184
-        return $this->is_custom_post_type;
185
-    }
186
-
187
-
188
-    /**
189
-     * @param bool $is_custom_post_type
190
-     */
191
-    protected function setIsCustomPostType(bool $is_custom_post_type)
192
-    {
193
-        $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN);
194
-    }
195
-
196
-
197
-    /**
198
-     * @param int|float $value
199
-     * @return int
200
-     * @since $VID:$
201
-     */
202
-    public function parseInfiniteValue($value): int
203
-    {
204
-        $value = trim($value);
205
-        return $value === null
206
-               || $value === ''
207
-               || $value === '∞'
208
-               || $value === 'INF'
209
-               || $value === INF
210
-               || $value === EE_INF
211
-               || is_infinite((float) $value)
212
-            ? -1
213
-            : $value;
214
-    }
215
-
216
-
217
-    /**
218
-     * @param mixed $source
219
-     * @return EE_Base_Class|null
220
-     * @throws EE_Error
221
-     */
222
-    private function getModel($source): ?EE_Base_Class
223
-    {
224
-        // If it comes from a custom connection
225
-        // where the $source is already instantiated.
226
-        if ($source instanceof EE_Base_Class) {
227
-            return $source;
228
-        }
229
-        return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null;
230
-    }
231
-
232
-
233
-    /**
234
-     * @param mixed       $source  The source that's passed down the GraphQL queries
235
-     * @param array       $args    The inputArgs on the field
236
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
237
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
238
-     * @return EE_Base_Class|Deferred|string|null
239
-     * @throws EE_Error
240
-     * @throws InvalidDataTypeException
241
-     * @throws InvalidInterfaceException
242
-     * @throws UnexpectedEntityException
243
-     * @throws UserError
244
-     * @throws InvalidArgumentException
245
-     * @throws ReflectionException
246
-     * @since $VID:$
247
-     */
248
-    public function resolveField($source, array $args, AppContext $context, ResolveInfo $info)
249
-    {
250
-        $source = $source instanceof RootQuery ? $source : $this->getModel($source);
251
-
252
-        return $this->field_resolver->resolve($source, $args, $context, $info);
253
-    }
254
-
255
-
256
-    /**
257
-     * @param mixed      $payload The payload returned after mutation
258
-     * @param array      $args    The inputArgs on the field
259
-     * @param AppContext $context The AppContext passed down the GraphQL tree
260
-     * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null
261
-     * @throws EE_Error
262
-     */
263
-    public function resolveFromPayload($payload, array $args, AppContext $context)
264
-    {
265
-        if (empty($payload['id'])) {
266
-            return null;
267
-        }
268
-        return $this->model->get_one_by_ID($payload['id']);
269
-    }
270
-
271
-
272
-    /**
273
-     * Prepares a datetime value in ISO8601/RFC3339 format.
274
-     * It is assumed that the value of $datetime is in the format
275
-     * returned by EE_Base_Class::get_format().
276
-     *
277
-     * @param string        $datetime The datetime value.
278
-     * @param EE_Base_Class $source   The source object.
279
-     * @return string ISO8601/RFC3339 formatted datetime.
280
-     */
281
-    public function formatDatetime(string $datetime, EE_Base_Class $source): string
282
-    {
283
-        $format   = $source->get_format();
284
-        // create date object based on local timezone
285
-        $datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone()));
286
-        // change the timezone to UTC
287
-        $datetime->setTimezone(new DateTimeZone('UTC'));
288
-
289
-        return $datetime->format(DateTime::RFC3339);
290
-    }
291
-
292
-
293
-    /**
294
-     * Converts an object to JSON. The object must have a "toJson" method.
295
-     *
296
-     * @param string        $object   The object/value.
297
-     * @param EE_Base_Class $source   The source object.
298
-     * @return string JSON representation of the object.
299
-     */
300
-    public function toJson(JsonableInterface $object, EE_Base_Class $source): string
301
-    {
302
-        return $object->toJson();
303
-    }
38
+	/**
39
+	 * @var string $namespace The graphql namespace/prefix.
40
+	 */
41
+	protected $namespace = 'Espresso';
42
+
43
+	/**
44
+	 * @var EEM_Base $model
45
+	 */
46
+	protected $model;
47
+
48
+	/**
49
+	 * @var string $name
50
+	 */
51
+	protected $name = '';
52
+
53
+	/**
54
+	 * @var string $description
55
+	 */
56
+	protected $description = '';
57
+
58
+	/**
59
+	 * @var GraphQLFieldInterface[] $fields
60
+	 */
61
+	protected $fields = [];
62
+
63
+	/**
64
+	 * @var array $graphql_to_model_map
65
+	 */
66
+	protected $graphql_to_model_map = [];
67
+
68
+	/**
69
+	 * @var FieldResolver $field_resolver
70
+	 */
71
+	protected $field_resolver;
72
+
73
+	/**
74
+	 * @var bool $is_custom_post_type
75
+	 */
76
+	protected $is_custom_post_type = false;
77
+
78
+
79
+	/**
80
+	 * TypeBase constructor.
81
+	 *
82
+	 * @param EEM_Base|null $model
83
+	 */
84
+	public function __construct(EEM_Base $model = null)
85
+	{
86
+		$this->model = $model;
87
+		$this->setFields($this->getFields());
88
+		$this->field_resolver = new FieldResolver(
89
+			$this->model,
90
+			$this->getFieldsForResolver()
91
+		);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return GraphQLFieldInterface[]
97
+	 * @since $VID:$
98
+	 */
99
+	abstract protected function getFields(): array;
100
+
101
+
102
+	/**
103
+	 * @return string
104
+	 */
105
+	public function name(): string
106
+	{
107
+		return $this->name;
108
+	}
109
+
110
+
111
+	/**
112
+	 * @param string $name
113
+	 */
114
+	protected function setName(string $name)
115
+	{
116
+		$this->name = $name;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public function description(): string
124
+	{
125
+		return $this->description;
126
+	}
127
+
128
+
129
+	/**
130
+	 * @param string $description
131
+	 */
132
+	protected function setDescription(string $description)
133
+	{
134
+		$this->description = $description;
135
+	}
136
+
137
+
138
+	/**
139
+	 * @return GraphQLFieldInterface[]
140
+	 * @since $VID:$
141
+	 */
142
+	public function fields(): array
143
+	{
144
+		return (array) $this->fields;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param GraphQLFieldInterface[] $fields
150
+	 */
151
+	protected function setFields(array $fields)
152
+	{
153
+		foreach ($fields as $field) {
154
+			if ($field instanceof GraphQLField) {
155
+				$this->fields[] = $field;
156
+			}
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * Creates a key map for internal resolver.
163
+	 *
164
+	 * @return array
165
+	 * @since $VID:$
166
+	 */
167
+	public function getFieldsForResolver(): array
168
+	{
169
+		$fields = [];
170
+		foreach ($this->fields() as $field) {
171
+			if ($field->useForOutput()) {
172
+				$fields[ $field->name() ] = $field;
173
+			}
174
+		}
175
+		return $fields;
176
+	}
177
+
178
+
179
+	/**
180
+	 * @return bool
181
+	 */
182
+	public function isCustomPostType(): bool
183
+	{
184
+		return $this->is_custom_post_type;
185
+	}
186
+
187
+
188
+	/**
189
+	 * @param bool $is_custom_post_type
190
+	 */
191
+	protected function setIsCustomPostType(bool $is_custom_post_type)
192
+	{
193
+		$this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @param int|float $value
199
+	 * @return int
200
+	 * @since $VID:$
201
+	 */
202
+	public function parseInfiniteValue($value): int
203
+	{
204
+		$value = trim($value);
205
+		return $value === null
206
+			   || $value === ''
207
+			   || $value === '∞'
208
+			   || $value === 'INF'
209
+			   || $value === INF
210
+			   || $value === EE_INF
211
+			   || is_infinite((float) $value)
212
+			? -1
213
+			: $value;
214
+	}
215
+
216
+
217
+	/**
218
+	 * @param mixed $source
219
+	 * @return EE_Base_Class|null
220
+	 * @throws EE_Error
221
+	 */
222
+	private function getModel($source): ?EE_Base_Class
223
+	{
224
+		// If it comes from a custom connection
225
+		// where the $source is already instantiated.
226
+		if ($source instanceof EE_Base_Class) {
227
+			return $source;
228
+		}
229
+		return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null;
230
+	}
231
+
232
+
233
+	/**
234
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
235
+	 * @param array       $args    The inputArgs on the field
236
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
237
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
238
+	 * @return EE_Base_Class|Deferred|string|null
239
+	 * @throws EE_Error
240
+	 * @throws InvalidDataTypeException
241
+	 * @throws InvalidInterfaceException
242
+	 * @throws UnexpectedEntityException
243
+	 * @throws UserError
244
+	 * @throws InvalidArgumentException
245
+	 * @throws ReflectionException
246
+	 * @since $VID:$
247
+	 */
248
+	public function resolveField($source, array $args, AppContext $context, ResolveInfo $info)
249
+	{
250
+		$source = $source instanceof RootQuery ? $source : $this->getModel($source);
251
+
252
+		return $this->field_resolver->resolve($source, $args, $context, $info);
253
+	}
254
+
255
+
256
+	/**
257
+	 * @param mixed      $payload The payload returned after mutation
258
+	 * @param array      $args    The inputArgs on the field
259
+	 * @param AppContext $context The AppContext passed down the GraphQL tree
260
+	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null
261
+	 * @throws EE_Error
262
+	 */
263
+	public function resolveFromPayload($payload, array $args, AppContext $context)
264
+	{
265
+		if (empty($payload['id'])) {
266
+			return null;
267
+		}
268
+		return $this->model->get_one_by_ID($payload['id']);
269
+	}
270
+
271
+
272
+	/**
273
+	 * Prepares a datetime value in ISO8601/RFC3339 format.
274
+	 * It is assumed that the value of $datetime is in the format
275
+	 * returned by EE_Base_Class::get_format().
276
+	 *
277
+	 * @param string        $datetime The datetime value.
278
+	 * @param EE_Base_Class $source   The source object.
279
+	 * @return string ISO8601/RFC3339 formatted datetime.
280
+	 */
281
+	public function formatDatetime(string $datetime, EE_Base_Class $source): string
282
+	{
283
+		$format   = $source->get_format();
284
+		// create date object based on local timezone
285
+		$datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone()));
286
+		// change the timezone to UTC
287
+		$datetime->setTimezone(new DateTimeZone('UTC'));
288
+
289
+		return $datetime->format(DateTime::RFC3339);
290
+	}
291
+
292
+
293
+	/**
294
+	 * Converts an object to JSON. The object must have a "toJson" method.
295
+	 *
296
+	 * @param string        $object   The object/value.
297
+	 * @param EE_Base_Class $source   The source object.
298
+	 * @return string JSON representation of the object.
299
+	 */
300
+	public function toJson(JsonableInterface $object, EE_Base_Class $source): string
301
+	{
302
+		return $object->toJson();
303
+	}
304 304
 }
Please login to merge, or discard this patch.
core/services/container/Mirror.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -21,298 +21,298 @@
 block discarded – undo
21 21
 class Mirror
22 22
 {
23 23
 
24
-    /**
25
-     * @var ReflectionClass[]
26
-     */
27
-    private $classes = [];
28
-
29
-    /**
30
-     * @var ReflectionMethod[]
31
-     */
32
-    private $constructors = [];
33
-
34
-    /**
35
-     * @var ReflectionParameter[][]
36
-     */
37
-    private $parameters = [];
38
-
39
-    /**
40
-     * @var ReflectionParameter[][]
41
-     */
42
-    private $parameter_classes = [];
43
-
44
-    /**
45
-     * @var ReflectionProperty[][]
46
-     */
47
-    private $properties = [];
48
-
49
-    /**
50
-     * @var ReflectionMethod[][]
51
-     */
52
-    private $methods = [];
53
-
54
-    /**
55
-     * @var array
56
-     */
57
-    private $default_properties = [];
58
-
59
-    /**
60
-     * @var array
61
-     */
62
-    private $static_properties = [];
63
-
64
-
65
-    /**
66
-     * @param string $class_name
67
-     * @return ReflectionClass
68
-     * @throws ReflectionException
69
-     * @throws InvalidDataTypeException
70
-     */
71
-    public function getReflectionClass(string $class_name): ReflectionClass
72
-    {
73
-        if (! is_string($class_name)) {
74
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
75
-        }
76
-        if (! isset($this->classes[ $class_name ])) {
77
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
78
-        }
79
-        return $this->classes[ $class_name ];
80
-    }
81
-
82
-
83
-    /**
84
-     * @param string $class_name
85
-     * @return ReflectionMethod|null
86
-     * @throws InvalidDataTypeException
87
-     * @throws ReflectionException
88
-     */
89
-    public function getConstructor(string $class_name): ?ReflectionMethod
90
-    {
91
-        if (! is_string($class_name)) {
92
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
93
-        }
94
-        if (! isset($this->constructors[ $class_name ])) {
95
-            $reflection_class                  = $this->getReflectionClass($class_name);
96
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
97
-        }
98
-        return $this->constructors[ $class_name ];
99
-    }
100
-
101
-
102
-    /**
103
-     * @param ReflectionClass $reflection_class
104
-     * @return ReflectionMethod|null
105
-     * @throws InvalidDataTypeException
106
-     * @throws ReflectionException
107
-     */
108
-    public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod
109
-    {
110
-        return $this->getConstructor($reflection_class->getName());
111
-    }
112
-
113
-
114
-    /**
115
-     * @param string $class_name
116
-     * @return ReflectionParameter[]
117
-     * @throws InvalidDataTypeException
118
-     * @throws ReflectionException
119
-     */
120
-    public function getParameters(string $class_name): array
121
-    {
122
-        if (! isset($this->parameters[ $class_name ])) {
123
-            $constructor                     = $this->getConstructor($class_name);
124
-            $this->parameters[ $class_name ] = $constructor->getParameters();
125
-        }
126
-        return $this->parameters[ $class_name ];
127
-    }
128
-
129
-
130
-    /**
131
-     * @param ReflectionClass $reflection_class
132
-     * @return ReflectionParameter[]
133
-     * @throws InvalidDataTypeException
134
-     * @throws ReflectionException
135
-     */
136
-    public function getParametersFromReflection(ReflectionClass $reflection_class): array
137
-    {
138
-        return $this->getParameters($reflection_class->getName());
139
-    }
140
-
141
-
142
-    /**
143
-     * @param ReflectionMethod $constructor
144
-     * @return ReflectionParameter[]
145
-     * @throws InvalidDataTypeException
146
-     * @throws ReflectionException
147
-     */
148
-    public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array
149
-    {
150
-        return $this->getParameters($constructor->getDeclaringClass());
151
-    }
152
-
153
-
154
-    /**
155
-     * returns array of ReflectionParameter objects for parameters that are NOT optional
156
-     *
157
-     * @param string $class_name
158
-     * @return ReflectionParameter[]
159
-     * @throws InvalidDataTypeException
160
-     * @throws ReflectionException
161
-     */
162
-    public function getRequiredParameters(string $class_name): array
163
-    {
164
-        $required_parameters = [];
165
-        $parameters          = $this->getParameters($class_name);
166
-        foreach ($parameters as $parameter) {
167
-            if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) {
168
-                $required_parameters[] = $parameter;
169
-            }
170
-        }
171
-        return $required_parameters;
172
-    }
173
-
174
-
175
-    /**
176
-     * @param ReflectionParameter $param
177
-     * @param string              $class_name
178
-     * @param string              $index
179
-     * @return string|null
180
-     */
181
-    public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
182
-    {
183
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
184
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
185
-        }
186
-        if (! isset($this->parameter_classes[ $class_name ])) {
187
-            $this->parameter_classes[ $class_name ] = [];
188
-        }
189
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
190
-            $this->parameter_classes[ $class_name ][ $index ] = [];
191
-        }
192
-        // ReflectionParameter::getClass() is deprecated in PHP 8+
193
-        if (PHP_VERSION_ID >= 80000) {
194
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
195
-                $param->getType() instanceof ReflectionNamedType
196
-                    ? $param->getType()->getName()
197
-                    : null;
198
-        } else {
199
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
200
-                    ? $param->getClass()->getName()
201
-                    : null;
202
-        }
203
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
204
-    }
205
-
206
-
207
-    /**
208
-     * @param ReflectionParameter $param
209
-     * @param string              $class_name
210
-     * @param string              $index
211
-     * @return array|string|null
212
-     * @throws ReflectionException
213
-     */
214
-    public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
215
-    {
216
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
217
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
218
-        }
219
-        if (! isset($this->parameter_classes[ $class_name ])) {
220
-            $this->parameter_classes[ $class_name ] = [];
221
-        }
222
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
223
-            $this->parameter_classes[ $class_name ][ $index ] = [];
224
-        }
225
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
226
-            ? $param->getDefaultValue()
227
-            : null;
228
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
229
-    }
230
-
231
-
232
-    /**
233
-     * @param string $class_name
234
-     * @return ReflectionProperty[]
235
-     * @throws InvalidDataTypeException
236
-     * @throws ReflectionException
237
-     */
238
-    public function getProperties(string $class_name): array
239
-    {
240
-        if (! isset($this->properties[ $class_name ])) {
241
-            $reflection_class                = $this->getReflectionClass($class_name);
242
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
243
-        }
244
-        return $this->properties[ $class_name ];
245
-    }
246
-
247
-
248
-    /**
249
-     * @param ReflectionClass $reflection_class
250
-     * @return ReflectionProperty[]
251
-     * @throws InvalidDataTypeException
252
-     * @throws ReflectionException
253
-     */
254
-    public function getPropertiesFromReflection(ReflectionClass $reflection_class): array
255
-    {
256
-        return $this->getProperties($reflection_class->getName());
257
-    }
258
-
259
-
260
-    /**
261
-     * @param string $class_name
262
-     * @return ReflectionMethod[]
263
-     * @throws InvalidDataTypeException
264
-     * @throws ReflectionException
265
-     */
266
-    public function getMethods(string $class_name): array
267
-    {
268
-        if (! isset($this->methods[ $class_name ])) {
269
-            $reflection_class             = $this->getReflectionClass($class_name);
270
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
271
-        }
272
-        return $this->methods[ $class_name ];
273
-    }
274
-
275
-
276
-    /**
277
-     * @param ReflectionClass $reflection_class )
278
-     * @return ReflectionMethod[]
279
-     * @throws InvalidDataTypeException
280
-     * @throws ReflectionException
281
-     */
282
-    public function getMethodsFromReflection(ReflectionClass $reflection_class): array
283
-    {
284
-        return $this->getMethods($reflection_class->getName());
285
-    }
286
-
287
-
288
-    /**
289
-     * @param string $class_name
290
-     * @return array
291
-     * @throws InvalidDataTypeException
292
-     * @throws ReflectionException
293
-     */
294
-    public function getDefaultProperties(string $class_name): array
295
-    {
296
-        if (! isset($this->default_properties[ $class_name ])) {
297
-            $reflection_class                        = $this->getReflectionClass($class_name);
298
-            $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
299
-        }
300
-        return $this->default_properties[ $class_name ];
301
-    }
302
-
303
-
304
-    /**
305
-     * @param string $class_name
306
-     * @return array
307
-     * @throws InvalidDataTypeException
308
-     * @throws ReflectionException
309
-     */
310
-    public function getStaticProperties(string $class_name): array
311
-    {
312
-        if (! isset($this->static_properties[ $class_name ])) {
313
-            $reflection_class                       = $this->getReflectionClass($class_name);
314
-            $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
315
-        }
316
-        return $this->static_properties[ $class_name ];
317
-    }
24
+	/**
25
+	 * @var ReflectionClass[]
26
+	 */
27
+	private $classes = [];
28
+
29
+	/**
30
+	 * @var ReflectionMethod[]
31
+	 */
32
+	private $constructors = [];
33
+
34
+	/**
35
+	 * @var ReflectionParameter[][]
36
+	 */
37
+	private $parameters = [];
38
+
39
+	/**
40
+	 * @var ReflectionParameter[][]
41
+	 */
42
+	private $parameter_classes = [];
43
+
44
+	/**
45
+	 * @var ReflectionProperty[][]
46
+	 */
47
+	private $properties = [];
48
+
49
+	/**
50
+	 * @var ReflectionMethod[][]
51
+	 */
52
+	private $methods = [];
53
+
54
+	/**
55
+	 * @var array
56
+	 */
57
+	private $default_properties = [];
58
+
59
+	/**
60
+	 * @var array
61
+	 */
62
+	private $static_properties = [];
63
+
64
+
65
+	/**
66
+	 * @param string $class_name
67
+	 * @return ReflectionClass
68
+	 * @throws ReflectionException
69
+	 * @throws InvalidDataTypeException
70
+	 */
71
+	public function getReflectionClass(string $class_name): ReflectionClass
72
+	{
73
+		if (! is_string($class_name)) {
74
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
75
+		}
76
+		if (! isset($this->classes[ $class_name ])) {
77
+			$this->classes[ $class_name ] = new ReflectionClass($class_name);
78
+		}
79
+		return $this->classes[ $class_name ];
80
+	}
81
+
82
+
83
+	/**
84
+	 * @param string $class_name
85
+	 * @return ReflectionMethod|null
86
+	 * @throws InvalidDataTypeException
87
+	 * @throws ReflectionException
88
+	 */
89
+	public function getConstructor(string $class_name): ?ReflectionMethod
90
+	{
91
+		if (! is_string($class_name)) {
92
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
93
+		}
94
+		if (! isset($this->constructors[ $class_name ])) {
95
+			$reflection_class                  = $this->getReflectionClass($class_name);
96
+			$this->constructors[ $class_name ] = $reflection_class->getConstructor();
97
+		}
98
+		return $this->constructors[ $class_name ];
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param ReflectionClass $reflection_class
104
+	 * @return ReflectionMethod|null
105
+	 * @throws InvalidDataTypeException
106
+	 * @throws ReflectionException
107
+	 */
108
+	public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod
109
+	{
110
+		return $this->getConstructor($reflection_class->getName());
111
+	}
112
+
113
+
114
+	/**
115
+	 * @param string $class_name
116
+	 * @return ReflectionParameter[]
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws ReflectionException
119
+	 */
120
+	public function getParameters(string $class_name): array
121
+	{
122
+		if (! isset($this->parameters[ $class_name ])) {
123
+			$constructor                     = $this->getConstructor($class_name);
124
+			$this->parameters[ $class_name ] = $constructor->getParameters();
125
+		}
126
+		return $this->parameters[ $class_name ];
127
+	}
128
+
129
+
130
+	/**
131
+	 * @param ReflectionClass $reflection_class
132
+	 * @return ReflectionParameter[]
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws ReflectionException
135
+	 */
136
+	public function getParametersFromReflection(ReflectionClass $reflection_class): array
137
+	{
138
+		return $this->getParameters($reflection_class->getName());
139
+	}
140
+
141
+
142
+	/**
143
+	 * @param ReflectionMethod $constructor
144
+	 * @return ReflectionParameter[]
145
+	 * @throws InvalidDataTypeException
146
+	 * @throws ReflectionException
147
+	 */
148
+	public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array
149
+	{
150
+		return $this->getParameters($constructor->getDeclaringClass());
151
+	}
152
+
153
+
154
+	/**
155
+	 * returns array of ReflectionParameter objects for parameters that are NOT optional
156
+	 *
157
+	 * @param string $class_name
158
+	 * @return ReflectionParameter[]
159
+	 * @throws InvalidDataTypeException
160
+	 * @throws ReflectionException
161
+	 */
162
+	public function getRequiredParameters(string $class_name): array
163
+	{
164
+		$required_parameters = [];
165
+		$parameters          = $this->getParameters($class_name);
166
+		foreach ($parameters as $parameter) {
167
+			if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) {
168
+				$required_parameters[] = $parameter;
169
+			}
170
+		}
171
+		return $required_parameters;
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param ReflectionParameter $param
177
+	 * @param string              $class_name
178
+	 * @param string              $index
179
+	 * @return string|null
180
+	 */
181
+	public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
182
+	{
183
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
184
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
185
+		}
186
+		if (! isset($this->parameter_classes[ $class_name ])) {
187
+			$this->parameter_classes[ $class_name ] = [];
188
+		}
189
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
190
+			$this->parameter_classes[ $class_name ][ $index ] = [];
191
+		}
192
+		// ReflectionParameter::getClass() is deprecated in PHP 8+
193
+		if (PHP_VERSION_ID >= 80000) {
194
+			$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
195
+				$param->getType() instanceof ReflectionNamedType
196
+					? $param->getType()->getName()
197
+					: null;
198
+		} else {
199
+			$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
200
+					? $param->getClass()->getName()
201
+					: null;
202
+		}
203
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
204
+	}
205
+
206
+
207
+	/**
208
+	 * @param ReflectionParameter $param
209
+	 * @param string              $class_name
210
+	 * @param string              $index
211
+	 * @return array|string|null
212
+	 * @throws ReflectionException
213
+	 */
214
+	public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
215
+	{
216
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
217
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
218
+		}
219
+		if (! isset($this->parameter_classes[ $class_name ])) {
220
+			$this->parameter_classes[ $class_name ] = [];
221
+		}
222
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
223
+			$this->parameter_classes[ $class_name ][ $index ] = [];
224
+		}
225
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
226
+			? $param->getDefaultValue()
227
+			: null;
228
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
229
+	}
230
+
231
+
232
+	/**
233
+	 * @param string $class_name
234
+	 * @return ReflectionProperty[]
235
+	 * @throws InvalidDataTypeException
236
+	 * @throws ReflectionException
237
+	 */
238
+	public function getProperties(string $class_name): array
239
+	{
240
+		if (! isset($this->properties[ $class_name ])) {
241
+			$reflection_class                = $this->getReflectionClass($class_name);
242
+			$this->properties[ $class_name ] = $reflection_class->getProperties();
243
+		}
244
+		return $this->properties[ $class_name ];
245
+	}
246
+
247
+
248
+	/**
249
+	 * @param ReflectionClass $reflection_class
250
+	 * @return ReflectionProperty[]
251
+	 * @throws InvalidDataTypeException
252
+	 * @throws ReflectionException
253
+	 */
254
+	public function getPropertiesFromReflection(ReflectionClass $reflection_class): array
255
+	{
256
+		return $this->getProperties($reflection_class->getName());
257
+	}
258
+
259
+
260
+	/**
261
+	 * @param string $class_name
262
+	 * @return ReflectionMethod[]
263
+	 * @throws InvalidDataTypeException
264
+	 * @throws ReflectionException
265
+	 */
266
+	public function getMethods(string $class_name): array
267
+	{
268
+		if (! isset($this->methods[ $class_name ])) {
269
+			$reflection_class             = $this->getReflectionClass($class_name);
270
+			$this->methods[ $class_name ] = $reflection_class->getMethods();
271
+		}
272
+		return $this->methods[ $class_name ];
273
+	}
274
+
275
+
276
+	/**
277
+	 * @param ReflectionClass $reflection_class )
278
+	 * @return ReflectionMethod[]
279
+	 * @throws InvalidDataTypeException
280
+	 * @throws ReflectionException
281
+	 */
282
+	public function getMethodsFromReflection(ReflectionClass $reflection_class): array
283
+	{
284
+		return $this->getMethods($reflection_class->getName());
285
+	}
286
+
287
+
288
+	/**
289
+	 * @param string $class_name
290
+	 * @return array
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws ReflectionException
293
+	 */
294
+	public function getDefaultProperties(string $class_name): array
295
+	{
296
+		if (! isset($this->default_properties[ $class_name ])) {
297
+			$reflection_class                        = $this->getReflectionClass($class_name);
298
+			$this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
299
+		}
300
+		return $this->default_properties[ $class_name ];
301
+	}
302
+
303
+
304
+	/**
305
+	 * @param string $class_name
306
+	 * @return array
307
+	 * @throws InvalidDataTypeException
308
+	 * @throws ReflectionException
309
+	 */
310
+	public function getStaticProperties(string $class_name): array
311
+	{
312
+		if (! isset($this->static_properties[ $class_name ])) {
313
+			$reflection_class                       = $this->getReflectionClass($class_name);
314
+			$this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
315
+		}
316
+		return $this->static_properties[ $class_name ];
317
+	}
318 318
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function getReflectionClass(string $class_name): ReflectionClass
72 72
     {
73
-        if (! is_string($class_name)) {
73
+        if ( ! is_string($class_name)) {
74 74
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
75 75
         }
76
-        if (! isset($this->classes[ $class_name ])) {
77
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
76
+        if ( ! isset($this->classes[$class_name])) {
77
+            $this->classes[$class_name] = new ReflectionClass($class_name);
78 78
         }
79
-        return $this->classes[ $class_name ];
79
+        return $this->classes[$class_name];
80 80
     }
81 81
 
82 82
 
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function getConstructor(string $class_name): ?ReflectionMethod
90 90
     {
91
-        if (! is_string($class_name)) {
91
+        if ( ! is_string($class_name)) {
92 92
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
93 93
         }
94
-        if (! isset($this->constructors[ $class_name ])) {
94
+        if ( ! isset($this->constructors[$class_name])) {
95 95
             $reflection_class                  = $this->getReflectionClass($class_name);
96
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
96
+            $this->constructors[$class_name] = $reflection_class->getConstructor();
97 97
         }
98
-        return $this->constructors[ $class_name ];
98
+        return $this->constructors[$class_name];
99 99
     }
100 100
 
101 101
 
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function getParameters(string $class_name): array
121 121
     {
122
-        if (! isset($this->parameters[ $class_name ])) {
122
+        if ( ! isset($this->parameters[$class_name])) {
123 123
             $constructor                     = $this->getConstructor($class_name);
124
-            $this->parameters[ $class_name ] = $constructor->getParameters();
124
+            $this->parameters[$class_name] = $constructor->getParameters();
125 125
         }
126
-        return $this->parameters[ $class_name ];
126
+        return $this->parameters[$class_name];
127 127
     }
128 128
 
129 129
 
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
182 182
     {
183
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
184
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
183
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_name'])) {
184
+            return $this->parameter_classes[$class_name][$index]['param_class_name'];
185 185
         }
186
-        if (! isset($this->parameter_classes[ $class_name ])) {
187
-            $this->parameter_classes[ $class_name ] = [];
186
+        if ( ! isset($this->parameter_classes[$class_name])) {
187
+            $this->parameter_classes[$class_name] = [];
188 188
         }
189
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
190
-            $this->parameter_classes[ $class_name ][ $index ] = [];
189
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
190
+            $this->parameter_classes[$class_name][$index] = [];
191 191
         }
192 192
         // ReflectionParameter::getClass() is deprecated in PHP 8+
193 193
         if (PHP_VERSION_ID >= 80000) {
194
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] =
194
+            $this->parameter_classes[$class_name][$index]['param_class_name'] =
195 195
                 $param->getType() instanceof ReflectionNamedType
196 196
                     ? $param->getType()->getName()
197 197
                     : null;
198 198
         } else {
199
-            $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass()
199
+            $this->parameter_classes[$class_name][$index]['param_class_name'] = $param->getClass()
200 200
                     ? $param->getClass()->getName()
201 201
                     : null;
202 202
         }
203
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
203
+        return $this->parameter_classes[$class_name][$index]['param_class_name'];
204 204
     }
205 205
 
206 206
 
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
215 215
     {
216
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
217
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
216
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_default'])) {
217
+            return $this->parameter_classes[$class_name][$index]['param_class_default'];
218 218
         }
219
-        if (! isset($this->parameter_classes[ $class_name ])) {
220
-            $this->parameter_classes[ $class_name ] = [];
219
+        if ( ! isset($this->parameter_classes[$class_name])) {
220
+            $this->parameter_classes[$class_name] = [];
221 221
         }
222
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
223
-            $this->parameter_classes[ $class_name ][ $index ] = [];
222
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
223
+            $this->parameter_classes[$class_name][$index] = [];
224 224
         }
225
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
225
+        $this->parameter_classes[$class_name][$index]['param_class_default'] = $param->isDefaultValueAvailable()
226 226
             ? $param->getDefaultValue()
227 227
             : null;
228
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
228
+        return $this->parameter_classes[$class_name][$index]['param_class_default'];
229 229
     }
230 230
 
231 231
 
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public function getProperties(string $class_name): array
239 239
     {
240
-        if (! isset($this->properties[ $class_name ])) {
240
+        if ( ! isset($this->properties[$class_name])) {
241 241
             $reflection_class                = $this->getReflectionClass($class_name);
242
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
242
+            $this->properties[$class_name] = $reflection_class->getProperties();
243 243
         }
244
-        return $this->properties[ $class_name ];
244
+        return $this->properties[$class_name];
245 245
     }
246 246
 
247 247
 
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public function getMethods(string $class_name): array
267 267
     {
268
-        if (! isset($this->methods[ $class_name ])) {
268
+        if ( ! isset($this->methods[$class_name])) {
269 269
             $reflection_class             = $this->getReflectionClass($class_name);
270
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
270
+            $this->methods[$class_name] = $reflection_class->getMethods();
271 271
         }
272
-        return $this->methods[ $class_name ];
272
+        return $this->methods[$class_name];
273 273
     }
274 274
 
275 275
 
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function getDefaultProperties(string $class_name): array
295 295
     {
296
-        if (! isset($this->default_properties[ $class_name ])) {
296
+        if ( ! isset($this->default_properties[$class_name])) {
297 297
             $reflection_class                        = $this->getReflectionClass($class_name);
298
-            $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
298
+            $this->default_properties[$class_name] = $reflection_class->getDefaultProperties();
299 299
         }
300
-        return $this->default_properties[ $class_name ];
300
+        return $this->default_properties[$class_name];
301 301
     }
302 302
 
303 303
 
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
      */
310 310
     public function getStaticProperties(string $class_name): array
311 311
     {
312
-        if (! isset($this->static_properties[ $class_name ])) {
312
+        if ( ! isset($this->static_properties[$class_name])) {
313 313
             $reflection_class                       = $this->getReflectionClass($class_name);
314
-            $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
314
+            $this->static_properties[$class_name] = $reflection_class->getStaticProperties();
315 315
         }
316
-        return $this->static_properties[ $class_name ];
316
+        return $this->static_properties[$class_name];
317 317
     }
318 318
 }
Please login to merge, or discard this patch.