Code Duplication    Length = 19-20 lines in 2 locations

src/Charcoal/View/Mustache/MustacheEngine.php 2 locations

@@ 65-84 (lines=20) @@
62
     * @throws InvalidArgumentException If the given helper(s) are invalid.
63
     * @return self
64
     */
65
    public function setHelpers($helpers)
66
    {
67
        if ($helpers instanceof HelpersInterface) {
68
            $helpers = $helpers->toArray();
69
        }
70
71
        if (!is_array($helpers) && !$helpers instanceof Traversable) {
72
            throw new InvalidArgumentException(sprintf(
73
                'setHelpers expects an array of helpers, received %s',
74
                (is_object($helpers) ? get_class($helpers) : gettype($helpers))
75
            ));
76
        }
77
78
        $this->helpers = [];
79
        foreach ($helpers as $name => $helper) {
80
            $this->addHelper($name, $helper);
81
        }
82
83
        return $this;
84
    }
85
86
    /**
87
     * Merge (replacing or adding) the engine's helpers.
@@ 93-111 (lines=19) @@
90
     * @throws InvalidArgumentException If the given helper(s) are invalid.
91
     * @return self
92
     */
93
    public function mergeHelpers($helpers)
94
    {
95
        if ($helpers instanceof HelpersInterface) {
96
            $helpers = $helpers->toArray();
97
        }
98
99
        if (!is_array($helpers) && !$helpers instanceof Traversable) {
100
            throw new InvalidArgumentException(sprintf(
101
                'mergeHelpers expects an array of helpers, received %s',
102
                (is_object($helpers) ? get_class($helpers) : gettype($helpers))
103
            ));
104
        }
105
106
        foreach ($helpers as $name => $helper) {
107
            $this->addHelper($name, $helper);
108
        }
109
110
        return $this;
111
    }
112
113
    /**
114
     * Add a helper.