PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 / editors / application / analysis-features / enabled-analysis-features-repository.php

enabled-analysis-features-repository.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/editors/application/analysis-features/enabled-analysis-features-repository.php

77 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\Editors\Application\Analysis_Features;
5
6 use Yoast\WP\SEO\Editors\Domain\Analysis_Features\Analysis_Feature;
7 use Yoast\WP\SEO\Editors\Domain\Analysis_Features\Analysis_Feature_Interface;
8 use Yoast\WP\SEO\Editors\Domain\Analysis_Features\Analysis_Features_List;
9
10 /**
11 * The repository to get all enabled features.
12 *
13 * @makePublic
14 */
15 class Enabled_Analysis_Features_Repository {
16
17 /**
18 * All plugin features.
19 *
20 * @var Analysis_Feature_Interface[]
21 */
22 private $plugin_features;
23
24 /**
25 * The list of analysis features.
26 *
27 * @var Analysis_Features_List
28 */
29 private $enabled_analysis_features;
30
31 /**
32 * The constructor.
33 *
34 * @param Analysis_Feature_Interface ...$plugin_features All analysis objects.
35 */
36 public function __construct( Analysis_Feature_Interface ...$plugin_features ) {
37 $this->enabled_analysis_features = new Analysis_Features_List();
38 $this->plugin_features = $plugin_features;
39 }
40
41 /**
42 * Returns the analysis list.
43 *
44 * @return Analysis_Features_List The analysis list.
45 */
46 public function get_enabled_features(): Analysis_Features_List {
47 if ( \count( $this->enabled_analysis_features->parse_to_legacy_array() ) === 0 ) {
48 foreach ( $this->plugin_features as $plugin_feature ) {
49 $analysis_feature = new Analysis_Feature( $plugin_feature->is_enabled(), $plugin_feature->get_name(), $plugin_feature->get_legacy_key() );
50 $this->enabled_analysis_features->add_feature( $analysis_feature );
51 }
52 }
53
54 return $this->enabled_analysis_features;
55 }
56
57 /**
58 * Returns the analysis list for the given names.
59 *
60 * @param array<string> $feature_names The feature names to include.
61 *
62 * @return Analysis_Features_List The analysis list.
63 */
64 public function get_features_by_keys( array $feature_names ): Analysis_Features_List {
65 $enabled_analysis_features = new Analysis_Features_List();
66
67 foreach ( $this->plugin_features as $plugin_feature ) {
68 if ( \in_array( $plugin_feature->get_name(), $feature_names, true ) ) {
69 $analysis_feature = new Analysis_Feature( $plugin_feature->is_enabled(), $plugin_feature->get_name(), $plugin_feature->get_legacy_key() );
70 $enabled_analysis_features->add_feature( $analysis_feature );
71 }
72 }
73
74 return $enabled_analysis_features;
75 }
76 }
77