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

Yoast / wordpress-seo / 6987097851

25 Nov 2023 04:49AM UTC coverage: 49.206% (-0.1%) from 49.302%
6987097851

push

github

web-flow
Merge pull request #20878 from Yoast/JRF/ghactions-minor-tweak

GH Actions: update a few links in inline comments

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

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

0.0
/src/values/robots/user-agent-list.php
1
<?php
2

3
namespace Yoast\WP\SEO\Values\Robots;
4

5
/**
6
 * Class User_Agent_List
7
 */
8
class User_Agent_List {
9

10
        /**
11
         * The list of user agents.
12
         *
13
         * @var array
14
         */
15
        private $user_agent_list;
16

17
        /**
18
         * User Agent list constructor.
19
         */
20
        public function __construct() {
×
21
                $this->user_agent_list = [];
×
22
        }
23

24
        /**
25
         * Checks if given user_agent is already registered.
26
         *
27
         * @param string $user_agent The user agent identifier.
28
         *
29
         * @return bool
30
         */
31
        public function has_user_agent( $user_agent ) {
×
32
                return \array_key_exists( $user_agent, $this->user_agent_list );
×
33
        }
34

35
        /**
36
         * Gets the user agent object. If it is not yet registered it creates it.
37
         *
38
         * @param string $user_agent The user agent identifier.
39
         *
40
         * @return User_Agent
41
         */
42
        public function get_user_agent( $user_agent ) {
×
43
                if ( $this->has_user_agent( $user_agent ) ) {
×
44
                        return $this->user_agent_list[ $user_agent ];
×
45
                }
46

47
                $this->user_agent_list[ $user_agent ] = new User_Agent( $user_agent );
×
48

49
                return $this->user_agent_list[ $user_agent ];
×
50
        }
51

52
        /**
53
         * Gets the list of user agents.
54
         *
55
         * @return array
56
         */
57
        public function get_user_agents() {
×
58
                return $this->user_agent_list;
×
59
        }
60

61
        /**
62
         * Gets a list of all disallow directives by user agent.
63
         *
64
         * @return array
65
         */
66
        public function get_disallow_directives() {
×
67
                $directives = [];
×
68
                foreach ( $this->user_agent_list as $user_agent ) {
×
69
                        $directives[ $user_agent->get_user_agent() ] = $user_agent->get_disallow_paths();
×
70
                }
71

72
                return $directives;
×
73
        }
74

75
        /**
76
         * Gets a list of all sallow directives by user agent.
77
         *
78
         * @return array
79
         */
80
        public function get_allow_directives() {
×
81
                $directives = [];
×
82
                foreach ( $this->user_agent_list as $user_agent ) {
×
83
                        $directives[ $user_agent->get_user_agent() ] = $user_agent->get_allow_paths();
×
84
                }
85

86
                return $directives;
×
87
        }
88
}
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