PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 19.0
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v19.0
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 / schema-helpers-surface.php

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

81 lines 1.8 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\Helpers\Schema;
6 use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ContainerInterface;
7
8 /**
9 * Class Schema_Helpers_Surface.
10 *
11 * Surface for the indexables.
12 *
13 * @property Schema\Article_Helper $article
14 * @property Schema\HTML_Helper $html
15 * @property Schema\ID_Helper $id
16 * @property Schema\Image_Helper $image
17 * @property Schema\Language_Helper $language
18 */
19 class Schema_Helpers_Surface {
20
21 /**
22 * The DI container.
23 *
24 * @var ContainerInterface
25 */
26 private $container;
27
28 /**
29 * Helpers that should be fully capitalized.
30 *
31 * @var array
32 */
33 private $capitalized_helpers = [ 'html', 'id' ];
34
35 /**
36 * Loader constructor.
37 *
38 * @param ContainerInterface $container The dependency injection container.
39 */
40 public function __construct( ContainerInterface $container ) {
41 $this->container = $container;
42 }
43
44 /**
45 * Magic getter for getting helper classes.
46 *
47 * @param string $helper The helper to get.
48 *
49 * @return mixed The helper class.
50 */
51 public function __get( $helper ) {
52 return $this->container->get( $this->get_helper_class( $helper ) );
53 }
54
55 /**
56 * Magic isset for ensuring helper exists.
57 *
58 * @param string $helper The helper to get.
59 *
60 * @return bool The helper class.
61 */
62 public function __isset( $helper ) {
63 return $this->container->has( $this->get_helper_class( $helper ) );
64 }
65
66 /**
67 * Get the class name from a helper slug
68 *
69 * @param string $helper The name of the helper.
70 *
71 * @return string
72 */
73 protected function get_helper_class( $helper ) {
74 if ( \in_array( $helper, $this->capitalized_helpers, true ) ) {
75 $helper = \strtoupper( $helper );
76 }
77 $helper = \implode( '_', \array_map( 'ucfirst', \explode( '_', $helper ) ) );
78 return "Yoast\WP\SEO\Helpers\Schema\\{$helper}_Helper";
79 }
80 }
81