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

timber / timber / 5690593717

pending completion
5690593717

Pull #1617

github

web-flow
Merge f587ceffa into b563d274e
Pull Request #1617: 2.x

4433 of 4433 new or added lines in 57 files covered. (100.0%)

3931 of 4433 relevant lines covered (88.68%)

58.28 hits per line

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

87.5
/src/Factory/PagesMenuFactory.php
1
<?php
2

3
namespace Timber\Factory;
4

5
use Timber\CoreInterface;
6
use Timber\PagesMenu;
7

8
/**
9
 * Internal API class for instantiating Menus
10
 */
11
class PagesMenuFactory
12
{
13
    /**
14
     * Gets a menu with pages from get_pages().
15
     *
16
     * @param array $args Optional. Args for get_pages().
17
     *
18
     * @return \Timber\CoreInterface
19
     */
20
    public function from_pages(array $args = [])
21
    {
22
        return $this->build($args);
10✔
23
    }
24

25
    /**
26
     * Gets the pages menu class.
27
     *
28
     * @internal
29
     *
30
     * @return string
31
     */
32
    protected function get_menu_class($args): string
33
    {
34
        /**
35
         * Filters the class used for different menus.
36
         *
37
         * Read more about this in the documentation for [Pages Menu Class filter](https://timber.github.io/docs/v2/guides/class-maps/#the-pages-menu-class-filter).
38
         *
39
         * @since 2.0.0
40
         * @example
41
         * ```
42
         * add_filter( 'timber/pages_menu/class', function( $class ) {
43
         *     return ExtendedPagesMenu::class;
44
         * } );
45
         * ```
46
         *
47
         * @param string $class The pages menu class to use.
48
         * @param array  $args  The arguments passed to `Timber::get_pages_menu()`.
49
         */
50
        $class = \apply_filters('timber/pages_menu/class', PagesMenu::class, $args);
10✔
51

52
        // If class is a callable, call it to get the actual class name
53
        if (\is_callable($class)) {
10✔
54
            $class = $class($args);
×
55
        }
56

57
        // Fallback on the default class.
58
        $class = $class ?? PagesMenu::class;
10✔
59

60
        return $class;
10✔
61
    }
62

63
    /**
64
     * Build menu
65
     *
66
     * @param array $args Optional. Args for get_pages().
67
     * @return CoreInterface
68
     */
69
    protected function build(array $args = []): CoreInterface
70
    {
71
        $class = $this->get_menu_class($args);
10✔
72

73
        return $class::build(null, $args);
10✔
74
    }
75
}
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