Completed
Branch dependabot/composer/wp-graphql... (5a0e42)
by
unknown
18:09 queued 13:06
created
core/domain/entities/route_match/MatchAllRouteSpecifications.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     public function isMatchingRoute()
24 24
     {
25 25
         foreach ($this->specifications as $specification) {
26
-            if (! $specification->isMatchingRoute()) {
26
+            if ( ! $specification->isMatchingRoute()) {
27 27
                 return false;
28 28
             }
29 29
         }
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
  */
14 14
 class MatchAllRouteSpecifications extends MultiRouteSpecification
15 15
 {
16
-    /**
17
-     * returns true if current request matches specification
18
-     *
19
-     * @since 4.9.71.p
20
-     * @return boolean
21
-     */
22
-    public function isMatchingRoute()
23
-    {
24
-        foreach ($this->specifications as $specification) {
25
-            if (! $specification->isMatchingRoute()) {
26
-                return false;
27
-            }
28
-        }
29
-        return true;
30
-    }
16
+	/**
17
+	 * returns true if current request matches specification
18
+	 *
19
+	 * @since 4.9.71.p
20
+	 * @return boolean
21
+	 */
22
+	public function isMatchingRoute()
23
+	{
24
+		foreach ($this->specifications as $specification) {
25
+			if (! $specification->isMatchingRoute()) {
26
+				return false;
27
+			}
28
+		}
29
+		return true;
30
+	}
31 31
 }
Please login to merge, or discard this patch.
core/services/route_match/RouteMatchSpecificationManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
115 115
     {
116 116
         /** @var RouteMatchSpecificationInterface $specification */
117 117
         $specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
-        if (! $specification instanceof $routeMatchSpecificationFqcn) {
118
+        if ( ! $specification instanceof $routeMatchSpecificationFqcn) {
119 119
             throw new InvalidClassException($routeMatchSpecificationFqcn);
120 120
         }
121 121
         return $specification->isMatchingRoute();
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -25,122 +25,122 @@
 block discarded – undo
25 25
  */
26 26
 class RouteMatchSpecificationManager
27 27
 {
28
-    /**
29
-     * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications
30
-     */
31
-    private $specifications;
28
+	/**
29
+	 * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications
30
+	 */
31
+	private $specifications;
32 32
 
33
-    /**
34
-     * @var RouteMatchSpecificationFactory $specifications_factory
35
-     */
36
-    private $specifications_factory;
33
+	/**
34
+	 * @var RouteMatchSpecificationFactory $specifications_factory
35
+	 */
36
+	private $specifications_factory;
37 37
 
38 38
 
39
-    /**
40
-     * RouteMatchSpecificationManager constructor.
41
-     *
42
-     * @param RouteMatchSpecificationCollection $specifications
43
-     * @param RouteMatchSpecificationFactory    $specifications_factory
44
-     */
45
-    public function __construct(
46
-        RouteMatchSpecificationCollection $specifications,
47
-        RouteMatchSpecificationFactory $specifications_factory
48
-    ) {
49
-        $this->specifications = $specifications;
50
-        $this->specifications_factory = $specifications_factory;
51
-        add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize'));
52
-    }
39
+	/**
40
+	 * RouteMatchSpecificationManager constructor.
41
+	 *
42
+	 * @param RouteMatchSpecificationCollection $specifications
43
+	 * @param RouteMatchSpecificationFactory    $specifications_factory
44
+	 */
45
+	public function __construct(
46
+		RouteMatchSpecificationCollection $specifications,
47
+		RouteMatchSpecificationFactory $specifications_factory
48
+	) {
49
+		$this->specifications = $specifications;
50
+		$this->specifications_factory = $specifications_factory;
51
+		add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize'));
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Perform any early setup required for block editors to functions
57
-     *
58
-     * @return void
59
-     * @throws CollectionLoaderException
60
-     * @throws CollectionDetailsException
61
-     */
62
-    public function initialize()
63
-    {
64
-        $this->populateSpecificationCollection();
65
-    }
55
+	/**
56
+	 * Perform any early setup required for block editors to functions
57
+	 *
58
+	 * @return void
59
+	 * @throws CollectionLoaderException
60
+	 * @throws CollectionDetailsException
61
+	 */
62
+	public function initialize()
63
+	{
64
+		$this->populateSpecificationCollection();
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * @return CollectionInterface|RouteMatchSpecificationInterface[]
70
-     * @throws CollectionLoaderException
71
-     * @throws CollectionDetailsException
72
-     * @since 4.9.71.p
73
-     */
74
-    private function populateSpecificationCollection()
75
-    {
76
-        $loader = new CollectionLoader(
77
-            new CollectionDetails(
78
-                // collection name
79
-                RouteMatchSpecificationCollection::COLLECTION_NAME,
80
-                // collection interface
81
-                'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',
82
-                // FQCNs for classes to add (all classes within each namespace will be loaded)
83
-                apply_filters(
84
-                    'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs',
85
-                    array(
86
-                        'EventEspresso\core\domain\entities\route_match\specifications\admin',
87
-                        'EventEspresso\core\domain\entities\route_match\specifications\frontend',
88
-                    )
89
-                ),
90
-                // filepaths to classes to add
91
-                array(),
92
-                // file mask to use if parsing folder for files to add
93
-                '',
94
-                // what to use as identifier for collection entities
95
-                // using CLASS NAME prevents duplicates (works like a singleton)
96
-                CollectionDetails::ID_CLASS_NAME
97
-            ),
98
-            $this->specifications,
99
-            null,
100
-            $this->specifications_factory
101
-        );
102
-        return $loader->getCollection();
103
-    }
68
+	/**
69
+	 * @return CollectionInterface|RouteMatchSpecificationInterface[]
70
+	 * @throws CollectionLoaderException
71
+	 * @throws CollectionDetailsException
72
+	 * @since 4.9.71.p
73
+	 */
74
+	private function populateSpecificationCollection()
75
+	{
76
+		$loader = new CollectionLoader(
77
+			new CollectionDetails(
78
+				// collection name
79
+				RouteMatchSpecificationCollection::COLLECTION_NAME,
80
+				// collection interface
81
+				'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',
82
+				// FQCNs for classes to add (all classes within each namespace will be loaded)
83
+				apply_filters(
84
+					'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs',
85
+					array(
86
+						'EventEspresso\core\domain\entities\route_match\specifications\admin',
87
+						'EventEspresso\core\domain\entities\route_match\specifications\frontend',
88
+					)
89
+				),
90
+				// filepaths to classes to add
91
+				array(),
92
+				// file mask to use if parsing folder for files to add
93
+				'',
94
+				// what to use as identifier for collection entities
95
+				// using CLASS NAME prevents duplicates (works like a singleton)
96
+				CollectionDetails::ID_CLASS_NAME
97
+			),
98
+			$this->specifications,
99
+			null,
100
+			$this->specifications_factory
101
+		);
102
+		return $loader->getCollection();
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches
108
-     *
109
-     * @param string $routeMatchSpecificationFqcn fully qualified class name
110
-     * @return bool
111
-     * @throws InvalidClassException
112
-     * @since 4.9.71.p
113
-     */
114
-    public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn)
115
-    {
116
-        /** @var RouteMatchSpecificationInterface $specification */
117
-        $specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
-        if (! $specification instanceof $routeMatchSpecificationFqcn) {
119
-            throw new InvalidClassException($routeMatchSpecificationFqcn);
120
-        }
121
-        return $specification->isMatchingRoute();
122
-    }
106
+	/**
107
+	 * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches
108
+	 *
109
+	 * @param string $routeMatchSpecificationFqcn fully qualified class name
110
+	 * @return bool
111
+	 * @throws InvalidClassException
112
+	 * @since 4.9.71.p
113
+	 */
114
+	public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn)
115
+	{
116
+		/** @var RouteMatchSpecificationInterface $specification */
117
+		$specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
+		if (! $specification instanceof $routeMatchSpecificationFqcn) {
119
+			throw new InvalidClassException($routeMatchSpecificationFqcn);
120
+		}
121
+		return $specification->isMatchingRoute();
122
+	}
123 123
 
124 124
 
125
-    /**
126
-     * Handy method for development that returns
127
-     * a list of existing RouteMatchSpecification classes
128
-     * matching the current request that can be used to identify it.
129
-     * If no matches are returned (or nothing acceptable)
130
-     * then create a new one that better matches your requirements.
131
-     *
132
-     * @return array
133
-     * @since 4.9.71.p
134
-     */
135
-    public function findRouteMatchSpecificationsMatchingCurrentRequest()
136
-    {
137
-        $matches = array();
138
-        foreach ($this->specifications as $specification) {
139
-            /** @var RouteMatchSpecificationInterface $specification */
140
-            if ($specification->isMatchingRoute()) {
141
-                $matches[] = get_class($specification);
142
-            }
143
-        }
144
-        return $matches;
145
-    }
125
+	/**
126
+	 * Handy method for development that returns
127
+	 * a list of existing RouteMatchSpecification classes
128
+	 * matching the current request that can be used to identify it.
129
+	 * If no matches are returned (or nothing acceptable)
130
+	 * then create a new one that better matches your requirements.
131
+	 *
132
+	 * @return array
133
+	 * @since 4.9.71.p
134
+	 */
135
+	public function findRouteMatchSpecificationsMatchingCurrentRequest()
136
+	{
137
+		$matches = array();
138
+		foreach ($this->specifications as $specification) {
139
+			/** @var RouteMatchSpecificationInterface $specification */
140
+			if ($specification->isMatchingRoute()) {
141
+				$matches[] = get_class($specification);
142
+			}
143
+		}
144
+		return $matches;
145
+	}
146 146
 }
Please login to merge, or discard this patch.
core/domain/entities/route_match/MultiRouteSpecification.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     public function __construct(array $specifications, RequestInterface $request)
32 32
     {
33 33
         foreach ($specifications as $specification) {
34
-            if (! $specification instanceof RouteMatchSpecificationInterface) {
34
+            if ( ! $specification instanceof RouteMatchSpecificationInterface) {
35 35
                 throw new InvalidEntityException(
36 36
                     $specification,
37 37
                     'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface'
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,29 +15,29 @@
 block discarded – undo
15 15
  */
16 16
 abstract class MultiRouteSpecification extends RouteMatchSpecification
17 17
 {
18
-    /**
19
-     * @var RouteMatchSpecificationInterface[] $specifications
20
-     */
21
-    protected $specifications;
18
+	/**
19
+	 * @var RouteMatchSpecificationInterface[] $specifications
20
+	 */
21
+	protected $specifications;
22 22
 
23
-    /**
24
-     * MultiRouteSpecification constructor.
25
-     *
26
-     * @param RouteMatchSpecificationInterface[] $specifications
27
-     * @param RequestInterface                   $request
28
-     * @throws InvalidEntityException
29
-     */
30
-    public function __construct(array $specifications, RequestInterface $request)
31
-    {
32
-        foreach ($specifications as $specification) {
33
-            if (! $specification instanceof RouteMatchSpecificationInterface) {
34
-                throw new InvalidEntityException(
35
-                    $specification,
36
-                    'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface'
37
-                );
38
-            }
39
-        }
40
-        $this->specifications = $specifications;
41
-        parent::__construct($request);
42
-    }
23
+	/**
24
+	 * MultiRouteSpecification constructor.
25
+	 *
26
+	 * @param RouteMatchSpecificationInterface[] $specifications
27
+	 * @param RequestInterface                   $request
28
+	 * @throws InvalidEntityException
29
+	 */
30
+	public function __construct(array $specifications, RequestInterface $request)
31
+	{
32
+		foreach ($specifications as $specification) {
33
+			if (! $specification instanceof RouteMatchSpecificationInterface) {
34
+				throw new InvalidEntityException(
35
+					$specification,
36
+					'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface'
37
+				);
38
+			}
39
+		}
40
+		$this->specifications = $specifications;
41
+		parent::__construct($request);
42
+	}
43 43
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/WordPressPostsEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class WordPressPostsEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * WordPressPostsEditor constructor.
23
-     *
24
-     * @param WordPressPostsEditorEdit $edit_post_route_match
25
-     * @param WordPressPostsEditorAddNew $create_post_route_match
26
-     * @param RequestInterface           $request
27
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        WordPressPostsEditorEdit $edit_post_route_match,
31
-        WordPressPostsEditorAddNew $create_post_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($edit_post_route_match, $create_post_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * WordPressPostsEditor constructor.
23
+	 *
24
+	 * @param WordPressPostsEditorEdit $edit_post_route_match
25
+	 * @param WordPressPostsEditorAddNew $create_post_route_match
26
+	 * @param RequestInterface           $request
27
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		WordPressPostsEditorEdit $edit_post_route_match,
31
+		WordPressPostsEditorAddNew $create_post_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($edit_post_route_match, $create_post_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoEventEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
  */
20 20
 class EspressoEventEditor extends MatchAnyRouteSpecification
21 21
 {
22
-    /**
23
-     * EspressoEventEditor constructor.
24
-     *
25
-     * @param EspressoEventEditorEdit   $edit_event_route_match
26
-     * @param EspressoEventEditorAddNew $create_event_route_match
27
-     * @param RequestInterface          $request
28
-     * @throws InvalidEntityException
29
-     */
30
-    public function __construct(
31
-        EspressoEventEditorEdit $edit_event_route_match,
32
-        EspressoEventEditorAddNew $create_event_route_match,
33
-        RequestInterface $request
34
-    ) {
35
-        parent::__construct(
36
-            array($edit_event_route_match, $create_event_route_match),
37
-            $request
38
-        );
39
-    }
22
+	/**
23
+	 * EspressoEventEditor constructor.
24
+	 *
25
+	 * @param EspressoEventEditorEdit   $edit_event_route_match
26
+	 * @param EspressoEventEditorAddNew $create_event_route_match
27
+	 * @param RequestInterface          $request
28
+	 * @throws InvalidEntityException
29
+	 */
30
+	public function __construct(
31
+		EspressoEventEditorEdit $edit_event_route_match,
32
+		EspressoEventEditorAddNew $create_event_route_match,
33
+		RequestInterface $request
34
+	) {
35
+		parent::__construct(
36
+			array($edit_event_route_match, $create_event_route_match),
37
+			$request
38
+		);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoVenueEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
  */
20 20
 class EspressoVenueEditor extends MatchAnyRouteSpecification
21 21
 {
22
-    /**
23
-     * EspressoVenueEditor constructor.
24
-     *
25
-     * @param EspressoVenueEditorEdit $edit_venue_route_match
26
-     * @param EspressoVenueEditorAddNew $create_venue_route_match
27
-     * @param RequestInterface          $request
28
-     * @throws InvalidEntityException
29
-     */
30
-    public function __construct(
31
-        EspressoVenueEditorEdit $edit_venue_route_match,
32
-        EspressoVenueEditorAddNew $create_venue_route_match,
33
-        RequestInterface $request
34
-    ) {
35
-        parent::__construct(
36
-            array($edit_venue_route_match, $create_venue_route_match),
37
-            $request
38
-        );
39
-    }
22
+	/**
23
+	 * EspressoVenueEditor constructor.
24
+	 *
25
+	 * @param EspressoVenueEditorEdit $edit_venue_route_match
26
+	 * @param EspressoVenueEditorAddNew $create_venue_route_match
27
+	 * @param RequestInterface          $request
28
+	 * @throws InvalidEntityException
29
+	 */
30
+	public function __construct(
31
+		EspressoVenueEditorEdit $edit_venue_route_match,
32
+		EspressoVenueEditorAddNew $create_venue_route_match,
33
+		RequestInterface $request
34
+	) {
35
+		parent::__construct(
36
+			array($edit_venue_route_match, $create_venue_route_match),
37
+			$request
38
+		);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoPostTypeEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class EspressoPostTypeEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * EspressoEventEditor constructor.
23
-     *
24
-     * @param EspressoStandardPostTypeEditor $standard_route_match
25
-     * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
-     * @param RequestInterface          $request
27
-     * @throws InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        EspressoStandardPostTypeEditor $standard_route_match,
31
-        EspressoAttendeePostTypeEditor $attendee_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($standard_route_match, $attendee_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * EspressoEventEditor constructor.
23
+	 *
24
+	 * @param EspressoStandardPostTypeEditor $standard_route_match
25
+	 * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
+	 * @param RequestInterface          $request
27
+	 * @throws InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		EspressoStandardPostTypeEditor $standard_route_match,
31
+		EspressoAttendeePostTypeEditor $attendee_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($standard_route_match, $attendee_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/WordPressPageEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class WordPressPageEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * WordPressPostsEditor constructor.
23
-     *
24
-     * @param WordPressPostsEditorEdit $edit_page_route_match
25
-     * @param WordPressPostsEditorAddNew $create_page_route_match
26
-     * @param RequestInterface           $request
27
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        WordPressPageEditorEdit $edit_page_route_match,
31
-        WordPressPageEditorAddNew $create_page_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($edit_page_route_match, $create_page_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * WordPressPostsEditor constructor.
23
+	 *
24
+	 * @param WordPressPostsEditorEdit $edit_page_route_match
25
+	 * @param WordPressPostsEditorAddNew $create_page_route_match
26
+	 * @param RequestInterface           $request
27
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		WordPressPageEditorEdit $edit_page_route_match,
31
+		WordPressPageEditorAddNew $create_page_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($edit_page_route_match, $create_page_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
core/entities/models/JsonModelSchema.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,22 +76,22 @@  discard block
 block discarded – undo
76 76
     public function getModelSchemaForFields(array $model_fields, array $schema)
77 77
     {
78 78
         foreach ($model_fields as $field => $model_field) {
79
-            if (! $model_field instanceof EE_Model_Field_Base) {
79
+            if ( ! $model_field instanceof EE_Model_Field_Base) {
80 80
                 continue;
81 81
             }
82
-            $schema['properties'][ $field ] = $model_field->getSchema();
82
+            $schema['properties'][$field] = $model_field->getSchema();
83 83
 
84 84
             // if this is a primary key field add the primary key item
85 85
             if ($model_field instanceof EE_Primary_Key_Field_Base) {
86
-                $schema['properties'][ $field ]['primary_key'] = true;
86
+                $schema['properties'][$field]['primary_key'] = true;
87 87
                 if ($model_field instanceof EE_Primary_Key_Int_Field) {
88
-                    $schema['properties'][ $field ]['readonly'] = true;
88
+                    $schema['properties'][$field]['readonly'] = true;
89 89
                 }
90 90
             }
91 91
 
92 92
             // if this is a foreign key field add the foreign key item
93 93
             if ($model_field instanceof EE_Foreign_Key_Field_Base) {
94
-                $schema['properties'][ $field ]['foreign_key'] = array(
94
+                $schema['properties'][$field]['foreign_key'] = array(
95 95
                     'description' => esc_html__(
96 96
                         'This is a foreign key the points to the given models.',
97 97
                         'event_espresso'
@@ -115,18 +115,18 @@  discard block
 block discarded – undo
115 115
     public function getModelSchemaForRelations(array $relations_on_model, array $schema)
116 116
     {
117 117
         foreach ($relations_on_model as $model_name => $relation) {
118
-            if (! $relation instanceof EE_Model_Relation_Base) {
118
+            if ( ! $relation instanceof EE_Model_Relation_Base) {
119 119
                 continue;
120 120
             }
121 121
             $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
122 122
                 ? strtolower($model_name)
123 123
                 : EEH_Inflector::pluralize_and_lower($model_name);
124
-            $schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
125
-            $schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
124
+            $schema['properties'][$model_name_for_schema] = $relation->getSchema();
125
+            $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name;
126 126
 
127 127
             // links schema
128
-            $links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
129
-            $schema['properties']['_links']['properties'][ $links_key ] = array(
128
+            $links_key = 'https://api.eventespresso.com/'.strtolower($model_name);
129
+            $schema['properties']['_links']['properties'][$links_key] = array(
130 130
                 'description' => esc_html__(
131 131
                     'Array of objects describing the link(s) for this relation resource.',
132 132
                     'event_espresso'
Please login to merge, or discard this patch.
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -24,256 +24,256 @@
 block discarded – undo
24 24
  */
25 25
 class JsonModelSchema
26 26
 {
27
-    /**
28
-     * @var EEM_Base
29
-     */
30
-    protected $model;
27
+	/**
28
+	 * @var EEM_Base
29
+	 */
30
+	protected $model;
31 31
 
32
-    /**
33
-     * @var CalculatedModelFields
34
-     */
35
-    protected $fields_calculator;
32
+	/**
33
+	 * @var CalculatedModelFields
34
+	 */
35
+	protected $fields_calculator;
36 36
 
37 37
 
38
-    /**
39
-     * JsonModelSchema constructor.
40
-     *
41
-     * @param EEM_Base              $model
42
-     * @param CalculatedModelFields $fields_calculator
43
-     */
44
-    public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
45
-    {
46
-        $this->model = $model;
47
-        $this->fields_calculator = $fields_calculator;
48
-    }
38
+	/**
39
+	 * JsonModelSchema constructor.
40
+	 *
41
+	 * @param EEM_Base              $model
42
+	 * @param CalculatedModelFields $fields_calculator
43
+	 */
44
+	public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
45
+	{
46
+		$this->model = $model;
47
+		$this->fields_calculator = $fields_calculator;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * Return the schema for a given model from a given model.
53
-     *
54
-     * @return array
55
-     */
56
-    public function getModelSchema()
57
-    {
58
-        return $this->getModelSchemaForRelations(
59
-            $this->model->relation_settings(),
60
-            $this->getModelSchemaForFields(
61
-                $this->model->field_settings(),
62
-                $this->getInitialSchemaStructure()
63
-            )
64
-        );
65
-    }
51
+	/**
52
+	 * Return the schema for a given model from a given model.
53
+	 *
54
+	 * @return array
55
+	 */
56
+	public function getModelSchema()
57
+	{
58
+		return $this->getModelSchemaForRelations(
59
+			$this->model->relation_settings(),
60
+			$this->getModelSchemaForFields(
61
+				$this->model->field_settings(),
62
+				$this->getInitialSchemaStructure()
63
+			)
64
+		);
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * Get the schema for a given set of model fields.
70
-     *
71
-     * @param EE_Model_Field_Base[] $model_fields
72
-     * @param array                  $schema
73
-     * @return array
74
-     */
75
-    public function getModelSchemaForFields(array $model_fields, array $schema)
76
-    {
77
-        foreach ($model_fields as $field => $model_field) {
78
-            if (! $model_field instanceof EE_Model_Field_Base) {
79
-                continue;
80
-            }
81
-            $schema['properties'][ $field ] = $model_field->getSchema();
68
+	/**
69
+	 * Get the schema for a given set of model fields.
70
+	 *
71
+	 * @param EE_Model_Field_Base[] $model_fields
72
+	 * @param array                  $schema
73
+	 * @return array
74
+	 */
75
+	public function getModelSchemaForFields(array $model_fields, array $schema)
76
+	{
77
+		foreach ($model_fields as $field => $model_field) {
78
+			if (! $model_field instanceof EE_Model_Field_Base) {
79
+				continue;
80
+			}
81
+			$schema['properties'][ $field ] = $model_field->getSchema();
82 82
 
83
-            // if this is a primary key field add the primary key item
84
-            if ($model_field instanceof EE_Primary_Key_Field_Base) {
85
-                $schema['properties'][ $field ]['primary_key'] = true;
86
-                if ($model_field instanceof EE_Primary_Key_Int_Field) {
87
-                    $schema['properties'][ $field ]['readonly'] = true;
88
-                }
89
-            }
83
+			// if this is a primary key field add the primary key item
84
+			if ($model_field instanceof EE_Primary_Key_Field_Base) {
85
+				$schema['properties'][ $field ]['primary_key'] = true;
86
+				if ($model_field instanceof EE_Primary_Key_Int_Field) {
87
+					$schema['properties'][ $field ]['readonly'] = true;
88
+				}
89
+			}
90 90
 
91
-            // if this is a foreign key field add the foreign key item
92
-            if ($model_field instanceof EE_Foreign_Key_Field_Base) {
93
-                $schema['properties'][ $field ]['foreign_key'] = array(
94
-                    'description' => esc_html__(
95
-                        'This is a foreign key the points to the given models.',
96
-                        'event_espresso'
97
-                    ),
98
-                    'type'        => 'array',
99
-                    'enum'        => $model_field->get_model_class_names_pointed_to(),
100
-                );
101
-            }
102
-        }
103
-        return $schema;
104
-    }
91
+			// if this is a foreign key field add the foreign key item
92
+			if ($model_field instanceof EE_Foreign_Key_Field_Base) {
93
+				$schema['properties'][ $field ]['foreign_key'] = array(
94
+					'description' => esc_html__(
95
+						'This is a foreign key the points to the given models.',
96
+						'event_espresso'
97
+					),
98
+					'type'        => 'array',
99
+					'enum'        => $model_field->get_model_class_names_pointed_to(),
100
+				);
101
+			}
102
+		}
103
+		return $schema;
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * Get the schema for a given set of model relations
109
-     *
110
-     * @param EE_Model_Relation_Base[] $relations_on_model
111
-     * @param array                    $schema
112
-     * @return array
113
-     */
114
-    public function getModelSchemaForRelations(array $relations_on_model, array $schema)
115
-    {
116
-        foreach ($relations_on_model as $model_name => $relation) {
117
-            if (! $relation instanceof EE_Model_Relation_Base) {
118
-                continue;
119
-            }
120
-            $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
121
-                ? strtolower($model_name)
122
-                : EEH_Inflector::pluralize_and_lower($model_name);
123
-            $schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
124
-            $schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
107
+	/**
108
+	 * Get the schema for a given set of model relations
109
+	 *
110
+	 * @param EE_Model_Relation_Base[] $relations_on_model
111
+	 * @param array                    $schema
112
+	 * @return array
113
+	 */
114
+	public function getModelSchemaForRelations(array $relations_on_model, array $schema)
115
+	{
116
+		foreach ($relations_on_model as $model_name => $relation) {
117
+			if (! $relation instanceof EE_Model_Relation_Base) {
118
+				continue;
119
+			}
120
+			$model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
121
+				? strtolower($model_name)
122
+				: EEH_Inflector::pluralize_and_lower($model_name);
123
+			$schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
124
+			$schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
125 125
 
126
-            // links schema
127
-            $links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
128
-            $schema['properties']['_links']['properties'][ $links_key ] = array(
129
-                'description' => esc_html__(
130
-                    'Array of objects describing the link(s) for this relation resource.',
131
-                    'event_espresso'
132
-                ),
133
-                'type' => 'array',
134
-                'readonly' => true,
135
-                'items' => array(
136
-                    'type' => 'object',
137
-                    'properties' => array(
138
-                        'href' => array(
139
-                            'type' => 'string',
140
-                            'description' => sprintf(
141
-                                // translators: placeholder is the model name for the relation.
142
-                                esc_html__(
143
-                                    'The link to the resource for the %s relation(s) to this entity',
144
-                                    'event_espresso'
145
-                                ),
146
-                                $model_name
147
-                            ),
148
-                        ),
149
-                        'single' => array(
150
-                            'type' => 'boolean',
151
-                            'description' => sprintf(
152
-                                // translators: placeholder is the model name for the relation.
153
-                                esc_html__(
154
-                                    'Whether or not there is only a single %s relation to this entity',
155
-                                    'event_espresso'
156
-                                ),
157
-                                $model_name
158
-                            ),
159
-                        ),
160
-                    ),
161
-                    'additionalProperties' => false
162
-                ),
163
-            );
164
-        }
165
-        return $schema;
166
-    }
126
+			// links schema
127
+			$links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
128
+			$schema['properties']['_links']['properties'][ $links_key ] = array(
129
+				'description' => esc_html__(
130
+					'Array of objects describing the link(s) for this relation resource.',
131
+					'event_espresso'
132
+				),
133
+				'type' => 'array',
134
+				'readonly' => true,
135
+				'items' => array(
136
+					'type' => 'object',
137
+					'properties' => array(
138
+						'href' => array(
139
+							'type' => 'string',
140
+							'description' => sprintf(
141
+								// translators: placeholder is the model name for the relation.
142
+								esc_html__(
143
+									'The link to the resource for the %s relation(s) to this entity',
144
+									'event_espresso'
145
+								),
146
+								$model_name
147
+							),
148
+						),
149
+						'single' => array(
150
+							'type' => 'boolean',
151
+							'description' => sprintf(
152
+								// translators: placeholder is the model name for the relation.
153
+								esc_html__(
154
+									'Whether or not there is only a single %s relation to this entity',
155
+									'event_espresso'
156
+								),
157
+								$model_name
158
+							),
159
+						),
160
+					),
161
+					'additionalProperties' => false
162
+				),
163
+			);
164
+		}
165
+		return $schema;
166
+	}
167 167
 
168 168
 
169
-    /**
170
-     * Outputs the schema header for a model.
171
-     *
172
-     * @return array
173
-     */
174
-    public function getInitialSchemaStructure()
175
-    {
176
-        return array(
177
-            '$schema'    => 'http://json-schema.org/draft-04/schema#',
178
-            'title'      => $this->model->get_this_model_name(),
179
-            'type'       => 'object',
180
-            'properties' => array(
181
-                'link' => array(
182
-                    'description' => esc_html__(
183
-                        'Link to event on WordPress site hosting events.',
184
-                        'event_espresso'
185
-                    ),
186
-                    'type' => 'string',
187
-                    'readonly' => true,
188
-                ),
189
-                '_links' => array(
190
-                    'description' => esc_html__(
191
-                        'Various links for resources related to the entity.',
192
-                        'event_espresso'
193
-                    ),
194
-                    'type' => 'object',
195
-                    'readonly' => true,
196
-                    'properties' => array(
197
-                        'self' => array(
198
-                            'description' => esc_html__(
199
-                                'Link to this entities resource.',
200
-                                'event_espresso'
201
-                            ),
202
-                            'type' => 'array',
203
-                            'items' => array(
204
-                                'type' => 'object',
205
-                                'properties' => array(
206
-                                    'href' => array(
207
-                                        'type' => 'string',
208
-                                    ),
209
-                                ),
210
-                                'additionalProperties' => false
211
-                            ),
212
-                            'readonly' => true
213
-                        ),
214
-                        'collection' => array(
215
-                            'description' => esc_html__(
216
-                                'Link to this entities collection resource.',
217
-                                'event_espresso'
218
-                            ),
219
-                            'type' => 'array',
220
-                            'items' => array(
221
-                                'type' => 'object',
222
-                                'properties' => array(
223
-                                    'href' => array(
224
-                                        'type' => 'string'
225
-                                    ),
226
-                                ),
227
-                                'additionalProperties' => false
228
-                            ),
229
-                            'readonly' => true
230
-                        ),
231
-                    ),
232
-                    'additionalProperties' => false,
233
-                ),
234
-                '_calculated_fields' => array_merge(
235
-                    $this->fields_calculator->getJsonSchemaForModel($this->model),
236
-                    array(
237
-                        '_protected' => $this->getProtectedFieldsSchema()
238
-                    )
239
-                ),
240
-                '_protected' => $this->getProtectedFieldsSchema()
241
-            ),
242
-            'additionalProperties' => false,
243
-        );
244
-    }
169
+	/**
170
+	 * Outputs the schema header for a model.
171
+	 *
172
+	 * @return array
173
+	 */
174
+	public function getInitialSchemaStructure()
175
+	{
176
+		return array(
177
+			'$schema'    => 'http://json-schema.org/draft-04/schema#',
178
+			'title'      => $this->model->get_this_model_name(),
179
+			'type'       => 'object',
180
+			'properties' => array(
181
+				'link' => array(
182
+					'description' => esc_html__(
183
+						'Link to event on WordPress site hosting events.',
184
+						'event_espresso'
185
+					),
186
+					'type' => 'string',
187
+					'readonly' => true,
188
+				),
189
+				'_links' => array(
190
+					'description' => esc_html__(
191
+						'Various links for resources related to the entity.',
192
+						'event_espresso'
193
+					),
194
+					'type' => 'object',
195
+					'readonly' => true,
196
+					'properties' => array(
197
+						'self' => array(
198
+							'description' => esc_html__(
199
+								'Link to this entities resource.',
200
+								'event_espresso'
201
+							),
202
+							'type' => 'array',
203
+							'items' => array(
204
+								'type' => 'object',
205
+								'properties' => array(
206
+									'href' => array(
207
+										'type' => 'string',
208
+									),
209
+								),
210
+								'additionalProperties' => false
211
+							),
212
+							'readonly' => true
213
+						),
214
+						'collection' => array(
215
+							'description' => esc_html__(
216
+								'Link to this entities collection resource.',
217
+								'event_espresso'
218
+							),
219
+							'type' => 'array',
220
+							'items' => array(
221
+								'type' => 'object',
222
+								'properties' => array(
223
+									'href' => array(
224
+										'type' => 'string'
225
+									),
226
+								),
227
+								'additionalProperties' => false
228
+							),
229
+							'readonly' => true
230
+						),
231
+					),
232
+					'additionalProperties' => false,
233
+				),
234
+				'_calculated_fields' => array_merge(
235
+					$this->fields_calculator->getJsonSchemaForModel($this->model),
236
+					array(
237
+						'_protected' => $this->getProtectedFieldsSchema()
238
+					)
239
+				),
240
+				'_protected' => $this->getProtectedFieldsSchema()
241
+			),
242
+			'additionalProperties' => false,
243
+		);
244
+	}
245 245
 
246
-    /**
247
-     * Returns an array of JSON schema to describe the _protected property on responses
248
-     * @since 4.9.74.p
249
-     * @return array
250
-     */
251
-    protected function getProtectedFieldsSchema()
252
-    {
253
-        return array(
254
-            'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
255
-            'type' => 'array',
256
-            'items' => array(
257
-                'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
258
-                'type' => 'string',
259
-                'readonly' => true,
260
-            ),
261
-            'readonly' => true
262
-        );
263
-    }
246
+	/**
247
+	 * Returns an array of JSON schema to describe the _protected property on responses
248
+	 * @since 4.9.74.p
249
+	 * @return array
250
+	 */
251
+	protected function getProtectedFieldsSchema()
252
+	{
253
+		return array(
254
+			'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
255
+			'type' => 'array',
256
+			'items' => array(
257
+				'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
258
+				'type' => 'string',
259
+				'readonly' => true,
260
+			),
261
+			'readonly' => true
262
+		);
263
+	}
264 264
 
265 265
 
266
-    /**
267
-     * Allows one to just use the object as a string to get the json.
268
-     * eg.
269
-     * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
270
-     * // if echoed, would convert schema to a json formatted string.
271
-     *
272
-     * @return string
273
-     */
274
-    public function __toString()
275
-    {
276
-        $schema = wp_json_encode($this->getModelSchema());
277
-        return is_string($schema) ? $schema : '';
278
-    }
266
+	/**
267
+	 * Allows one to just use the object as a string to get the json.
268
+	 * eg.
269
+	 * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
270
+	 * // if echoed, would convert schema to a json formatted string.
271
+	 *
272
+	 * @return string
273
+	 */
274
+	public function __toString()
275
+	{
276
+		$schema = wp_json_encode($this->getModelSchema());
277
+		return is_string($schema) ? $schema : '';
278
+	}
279 279
 }
Please login to merge, or discard this patch.