PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / surfaces / helpers-surface.php

helpers-surface.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/surfaces/helpers-surface.php

164 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Surfaces;
4
5 use Yoast\WP\SEO\Exceptions\Forbidden_Property_Mutation_Exception;
6 use Yoast\WP\SEO\Helpers;
7 use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ContainerInterface;
8
9 /**
10 * Class Helpers_Surface.
11 *
12 * Surface for the indexables.
13 *
14 * @property Helpers\Asset_Helper $asset
15 * @property Helpers\Author_Archive_Helper $author_archive
16 * @property Helpers\Blocks_Helper $blocks
17 * @property Helpers\Capability_Helper $capability
18 * @property Helpers\Current_Page_Helper $current_page
19 * @property Helpers\Date_Helper $date
20 * @property Helpers\Environment_Helper $environment
21 * @property Helpers\First_Time_Configuration_Notice_Helper $first_time_configuration_notice
22 * @property Helpers\Home_Url_Helper $home_url
23 * @property Helpers\Image_Helper $image
24 * @property Helpers\Indexable_Helper $indexable
25 * @property Helpers\Indexing_Helper $indexing
26 * @property Helpers\Input_Helper $input
27 * @property Helpers\Language_Helper $language
28 * @property Helpers\Meta_Helper $meta
29 * @property Helpers\Notification_Helper $notification
30 * @property Helpers\Options_Helper $options
31 * @property Helpers\Pagination_Helper $pagination
32 * @property Helpers\Permalink_Helper $permalink
33 * @property Helpers\Post_Helper $post
34 * @property Helpers\Post_Type_Helper $post_type
35 * @property Helpers\Primary_Term_Helper $primary_term
36 * @property Helpers\Product_Helper $product
37 * @property Helpers\Redirect_Helper $redirect
38 * @property Helpers\Require_File_Helper $require_file
39 * @property Helpers\Robots_Helper $robots
40 * @property Helpers\Short_Link_Helper $short_link
41 * @property Helpers\Site_Helper $site
42 * @property Helpers\String_Helper $string
43 * @property Helpers\Social_Profiles_Helper $social_profiles
44 * @property Helpers\Taxonomy_Helper $taxonomy
45 * @property Helpers\Url_Helper $url
46 * @property Helpers\User_Helper $user
47 * @property Helpers\Woocommerce_Helper $woocommerce
48 * @property Helpers\Wordpress_Helper $wordpress
49 */
50 class Helpers_Surface {
51
52 /**
53 * The DI container.
54 *
55 * @var ContainerInterface
56 */
57 private $container;
58
59 /**
60 * The open_graph helper namespace
61 *
62 * @var Open_Graph_Helpers_Surface
63 */
64 public $open_graph;
65
66 /**
67 * The schema helper namespace
68 *
69 * @var Schema_Helpers_Surface
70 */
71 public $schema;
72
73 /**
74 * The twitter helper namespace
75 *
76 * @var Twitter_Helpers_Surface
77 */
78 public $twitter;
79
80 /**
81 * Loader constructor.
82 *
83 * @param ContainerInterface $container The dependency injection container.
84 * @param Open_Graph_Helpers_Surface $open_graph The OpenGraph helpers surface.
85 * @param Schema_Helpers_Surface $schema The Schema helpers surface.
86 * @param Twitter_Helpers_Surface $twitter The Twitter helpers surface.
87 */
88 public function __construct(
89 ContainerInterface $container,
90 Open_Graph_Helpers_Surface $open_graph,
91 Schema_Helpers_Surface $schema,
92 Twitter_Helpers_Surface $twitter
93 ) {
94 $this->container = $container;
95 $this->open_graph = $open_graph;
96 $this->schema = $schema;
97 $this->twitter = $twitter;
98 }
99
100 /**
101 * Magic getter for getting helper classes.
102 *
103 * @param string $helper The helper to get.
104 *
105 * @return mixed The helper class.
106 */
107 public function __get( $helper ) {
108 return $this->container->get( $this->get_helper_class( $helper ) );
109 }
110
111 /**
112 * Magic isset for ensuring helper exists.
113 *
114 * @param string $helper The helper to get.
115 *
116 * @return bool Whether the helper exists.
117 */
118 public function __isset( $helper ) {
119 return $this->container->has( $this->get_helper_class( $helper ) );
120 }
121
122 /**
123 * Prevents setting dynamic properties and unsetting declared properties
124 * from an inaccessible context.
125 *
126 * @param string $name The property name.
127 * @param mixed $value The property value.
128 *
129 * @return void
130 *
131 * @throws Forbidden_Property_Mutation_Exception Set is never meant to be called.
132 */
133 public function __set( $name, $value ) { // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- __set must have a name and value - PHPCS #3715.
134 throw Forbidden_Property_Mutation_Exception::cannot_set_because_property_is_immutable( $name );
135 }
136
137 /**
138 * Prevents unsetting dynamic properties and unsetting declared properties
139 * from an inaccessible context.
140 *
141 * @param string $name The property name.
142 *
143 * @return void
144 *
145 * @throws Forbidden_Property_Mutation_Exception Unset is never meant to be called.
146 */
147 public function __unset( $name ) {
148 throw Forbidden_Property_Mutation_Exception::cannot_unset_because_property_is_immutable( $name );
149 }
150
151 /**
152 * Get the class name from a helper slug
153 *
154 * @param string $helper The name of the helper.
155 *
156 * @return string
157 */
158 protected function get_helper_class( $helper ) {
159 $helper = \implode( '_', \array_map( 'ucfirst', \explode( '_', $helper ) ) );
160
161 return "Yoast\WP\SEO\Helpers\\{$helper}_Helper";
162 }
163 }
164