• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / b05d07fc5b184095141e8ead75857d0154e04580

23 Jul 2024 07:52AM UTC coverage: 48.579% (-5.4%) from 53.976%
b05d07fc5b184095141e8ead75857d0154e04580

push

github

YoastBot
Bump version to 23.1

7399 of 13400 branches covered (55.22%)

Branch coverage included in aggregate %.

25129 of 53559 relevant lines covered (46.92%)

41942.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/src/surfaces/helpers-surface.php
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\Request_Helper                         $request
39
 * @property Helpers\Require_File_Helper                    $require_file
40
 * @property Helpers\Robots_Helper                          $robots
41
 * @property Helpers\Short_Link_Helper                      $short_link
42
 * @property Helpers\Site_Helper                            $site
43
 * @property Helpers\String_Helper                          $string
44
 * @property Helpers\Social_Profiles_Helper                 $social_profiles
45
 * @property Helpers\Taxonomy_Helper                        $taxonomy
46
 * @property Helpers\Url_Helper                             $url
47
 * @property Helpers\User_Helper                            $user
48
 * @property Helpers\Woocommerce_Helper                     $woocommerce
49
 * @property Helpers\Wordpress_Helper                       $wordpress
50
 */
51
class Helpers_Surface {
52

53
        /**
54
         * The DI container.
55
         *
56
         * @var ContainerInterface
57
         */
58
        private $container;
59

60
        /**
61
         * The open_graph helper namespace
62
         *
63
         * @var Open_Graph_Helpers_Surface
64
         */
65
        public $open_graph;
66

67
        /**
68
         * The schema helper namespace
69
         *
70
         * @var Schema_Helpers_Surface
71
         */
72
        public $schema;
73

74
        /**
75
         * The twitter helper namespace
76
         *
77
         * @var Twitter_Helpers_Surface
78
         */
79
        public $twitter;
80

81
        /**
82
         * Loader constructor.
83
         *
84
         * @param ContainerInterface         $container  The dependency injection container.
85
         * @param Open_Graph_Helpers_Surface $open_graph The OpenGraph helpers surface.
86
         * @param Schema_Helpers_Surface     $schema     The Schema helpers surface.
87
         * @param Twitter_Helpers_Surface    $twitter    The Twitter helpers surface.
88
         */
89
        public function __construct(
×
90
                ContainerInterface $container,
91
                Open_Graph_Helpers_Surface $open_graph,
92
                Schema_Helpers_Surface $schema,
93
                Twitter_Helpers_Surface $twitter
94
        ) {
95
                $this->container  = $container;
×
96
                $this->open_graph = $open_graph;
×
97
                $this->schema     = $schema;
×
98
                $this->twitter    = $twitter;
×
99
        }
100

101
        /**
102
         * Magic getter for getting helper classes.
103
         *
104
         * @param string $helper The helper to get.
105
         *
106
         * @return mixed The helper class.
107
         */
108
        public function __get( $helper ) {
48✔
109
                return $this->container->get( $this->get_helper_class( $helper ) );
48✔
110
        }
111

112
        /**
113
         * Magic isset for ensuring helper exists.
114
         *
115
         * @param string $helper The helper to get.
116
         *
117
         * @return bool Whether the helper exists.
118
         */
119
        public function __isset( $helper ) {
48✔
120
                return $this->container->has( $this->get_helper_class( $helper ) );
48✔
121
        }
122

123
        /**
124
         * Prevents setting dynamic properties and unsetting declared properties
125
         * from an inaccessible context.
126
         *
127
         * @param string $name  The property name.
128
         * @param mixed  $value The property value.
129
         *
130
         * @return void
131
         *
132
         * @throws Forbidden_Property_Mutation_Exception Set is never meant to be called.
133
         */
134
        public function __set( $name, $value ) { // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- __set must have a name and value - PHPCS #3715.
24✔
135
                throw Forbidden_Property_Mutation_Exception::cannot_set_because_property_is_immutable( $name );
24✔
136
        }
137

138
        /**
139
         * Prevents unsetting dynamic properties and unsetting declared properties
140
         * from an inaccessible context.
141
         *
142
         * @param string $name The property name.
143
         *
144
         * @return void
145
         *
146
         * @throws Forbidden_Property_Mutation_Exception Unset is never meant to be called.
147
         */
148
        public function __unset( $name ) {
24✔
149
                throw Forbidden_Property_Mutation_Exception::cannot_unset_because_property_is_immutable( $name );
24✔
150
        }
151

152
        /**
153
         * Get the class name from a helper slug
154
         *
155
         * @param string $helper The name of the helper.
156
         *
157
         * @return string
158
         */
159
        protected function get_helper_class( $helper ) {
×
160
                $helper = \implode( '_', \array_map( 'ucfirst', \explode( '_', $helper ) ) );
×
161

162
                return "Yoast\WP\SEO\Helpers\\{$helper}_Helper";
×
163
        }
164
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc