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

Yoast / wordpress-seo / ad2c4b607f7daae862318f3d8e622f745e25b2c7

18 Oct 2024 10:15AM UTC coverage: 49.406% (-5.2%) from 54.573%
ad2c4b607f7daae862318f3d8e622f745e25b2c7

push

github

web-flow
Merge pull request #21717 from Yoast/389-enable-typescript-in-the-package

Enable typescript in the yoastseo package

7549 of 13564 branches covered (55.65%)

Branch coverage included in aggregate %.

20 of 98 new or added lines in 1 file covered. (20.41%)

4289 existing lines in 144 files now uncovered.

25667 of 53667 relevant lines covered (47.83%)

42470.98 hits per line

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

0.0
/src/editors/framework/seo/posts/description-data-provider.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
3
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
4
namespace Yoast\WP\SEO\Editors\Framework\Seo\Posts;
5

6
use Yoast\WP\SEO\Editors\Domain\Seo\Description;
7
use Yoast\WP\SEO\Editors\Domain\Seo\Seo_Plugin_Data_Interface;
8
use Yoast\WP\SEO\Editors\Framework\Seo\Description_Data_Provider_Interface;
9
use Yoast\WP\SEO\Helpers\Date_Helper;
10
use Yoast\WP\SEO\Helpers\Options_Helper;
11

12
/**
13
 * Describes if the description SEO data.
14
 */
15
class Description_Data_Provider extends Abstract_Post_Seo_Data_Provider implements Description_Data_Provider_Interface {
16

17
        /**
18
         * The date helper.
19
         *
20
         * @var Date_Helper $date_helper
21
         */
22
        private $date_helper;
23

24
        /**
25
         * The options helper.
26
         *
27
         * @var Options_Helper $options_helper
28
         */
29
        private $options_helper;
30

31
        /**
32
         * The constructor.
33
         *
34
         * @param Date_Helper    $date_helper    The date helper.
35
         * @param Options_Helper $options_helper The options helper.
36
         */
UNCOV
37
        public function __construct( Date_Helper $date_helper, Options_Helper $options_helper ) {
×
UNCOV
38
                $this->date_helper    = $date_helper;
×
UNCOV
39
                $this->options_helper = $options_helper;
×
40
        }
41

42
        /**
43
         * Retrieves the description template.
44
         *
45
         * @return string The description template.
46
         */
UNCOV
47
        public function get_description_template(): string {
×
UNCOV
48
                return $this->get_template( 'metadesc' );
×
49
        }
50

51
        /**
52
         * Determines the date to be displayed in the snippet preview.
53
         *
54
         * @return string
55
         */
UNCOV
56
        public function get_description_date(): string {
×
UNCOV
57
                return $this->date_helper->format_translated( $this->post->post_date, 'M j, Y' );
×
58
        }
59

60
        /**
61
         * Retrieves a template.
62
         *
63
         * @param string $template_option_name The name of the option in which the template you want to get is saved.
64
         *
65
         * @return string
66
         */
UNCOV
67
        private function get_template( string $template_option_name ): string {
×
UNCOV
68
                $needed_option = $template_option_name . '-' . $this->post->post_type;
×
69

UNCOV
70
                if ( $this->options_helper->get( $needed_option, '' ) !== '' ) {
×
UNCOV
71
                        return $this->options_helper->get( $needed_option );
×
72
                }
73

UNCOV
74
                return '';
×
75
        }
76

77
        /**
78
         * Method to return the Description domain object with SEO data.
79
         *
80
         * @return Seo_Plugin_Data_Interface The specific seo data.
81
         */
UNCOV
82
        public function get_data(): Seo_Plugin_Data_Interface {
×
UNCOV
83
                return new Description( $this->get_description_date(), $this->get_description_template() );
×
84
        }
85
}
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