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

Yoast / wordpress-seo / de2c551191d9e8b57ebe98f4bd99a877f82f2006

15 Dec 2025 01:21PM UTC coverage: 50.97% (-0.001%) from 50.971%
de2c551191d9e8b57ebe98f4bd99a877f82f2006

push

github

pls78
Merge branch 'feature/schema_aggregator' of https://github.com/Yoast/wordpress-seo into feature/schema_aggregator

8327 of 15644 branches covered (53.23%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

8 existing lines in 1 file now uncovered.

31878 of 63235 relevant lines covered (50.41%)

45598.29 hits per line

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

0.0
/src/schema-aggregator/application/filtering/default-filter.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Schema_Aggregator\Application\Filtering;
4

5
use Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Property_Filter\Base_Schema_Node_Property_Filter;
6
use Yoast\WP\SEO\Schema_Aggregator\Domain\Schema_Piece_Collection;
7
use Yoast\WP\SEO\Schema_Aggregator\Infrastructure\Elements_Context_Map\Elements_Context_Map_Repository_Interface;
8

9
/**
10
 * Default filtering strategy implementation.
11
 */
12
class Default_Filter implements Filtering_Strategy_Interface {
13

14
        /**
15
         * The categories to filter.
16
         *
17
         * @var array<string>
18
         */
19
        private $filter_categories = [
20
                'action',
21
                'enumeration',
22
                'meta',
23
                'website',
24
        ];
25

26
        /**
27
         * The elements context map repository.
28
         *
29
         * @var Elements_Context_Map_Repository_Interface
30
         */
31
        private $elements_context_map_repository;
32

33
        /**
34
         * Class constructor.
35
         *
36
         * @param Elements_Context_Map_Repository_Interface $elements_context_map_repository The elements-context map repository.
37
         */
38
        public function __construct( Elements_Context_Map_Repository_Interface $elements_context_map_repository ) {
×
UNCOV
39
                $this->elements_context_map_repository = $elements_context_map_repository;
×
40
        }
41

42
        /**
43
         * Applies filtering to the given schema.
44
         *
45
         * @param Schema_Piece_Collection $schema The schema to be filtered.
46
         *
47
         * @return Schema_Piece_Collection The filtered schema.
48
         */
49
        public function filter( Schema_Piece_Collection $schema ): Schema_Piece_Collection {
×
50
                $filtered_schema      = [];
×
51
                $elements_context_map = $this->elements_context_map_repository->get_map();
×
52
                foreach ( $schema->to_array() as $schema_piece ) {
×
53
                        $should_keep = true;
×
54
                        foreach ( $this->filter_categories as $category ) {
×
55
                                if ( \in_array( $schema_piece->get_type(), $elements_context_map[ $category ], true ) ) {
×
56
                                        $filter_class_name = 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Filter\\' . $schema_piece->get_type() . '_Schema_Node_Filter';
×
57
                                        if ( \class_exists( $filter_class_name ) && \is_a( $filter_class_name, 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Filter\Schema_Node_Filter_Interface', true ) ) {
×
UNCOV
58
                                                $should_keep = ( new $filter_class_name() )->filter( $schema, $schema_piece );
×
59
                                        }
60
                                        else {
UNCOV
61
                                                $should_keep = false;
×
62
                                        }
UNCOV
63
                                        break;
×
64
                                }
65
                        }
66
                        if ( $should_keep ) {
×
67
                                $properties_filter_class_name = 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Property_Filter\\' . $schema_piece->get_type() . '_Schema_Node_Property_Filter';
×
68
                                if ( \class_exists( $properties_filter_class_name ) && \is_a( $properties_filter_class_name, 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Property_Filter\Schema_Node_Property_Filter_Interface', true ) ) {
×
UNCOV
69
                                        $schema_piece = ( new $properties_filter_class_name() )->filter_properties( $schema_piece );
×
70
                                }
71
                                else {
UNCOV
72
                                        $schema_piece = ( new Base_Schema_Node_Property_Filter() )->filter_properties( $schema_piece );
×
73
                                }
UNCOV
74
                                $filtered_schema[] = $schema_piece;
×
75
                        }
76
                }
UNCOV
77
                return new Schema_Piece_Collection( $filtered_schema );
×
78
        }
79
}
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