Code Duplication    Length = 15-16 lines in 2 locations

src/allejo/stakx/Core/StakxLogger.php 1 location

@@ 145-159 (lines=15) @@
142
     *
143
     * @return string
144
     */
145
    private function interpolate($message, array $context)
146
    {
147
        // build a replacement array with braces around the context keys
148
        $replace = array();
149
        foreach ($context as $key => $val)
150
        {
151
            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')))
152
            {
153
                $replace[sprintf('{%s}', $key)] = $val;
154
            }
155
        }
156
157
        // interpolate replacement values into the message and return
158
        return strtr($message, $replace);
159
    }
160
}
161

src/allejo/stakx/Utilities/StrUtils.php 1 location

@@ 22-37 (lines=16) @@
19
     *
20
     * @return string
21
     */
22
    public static function interpolate($message, array $context)
23
    {
24
        // build a replacement array with braces around the context keys
25
        $replace = array();
26
27
        foreach ($context as $key => $val)
28
        {
29
            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')))
30
            {
31
                $replace[sprintf('{%s}', $key)] = $val;
32
            }
33
        }
34
35
        // interpolate replacement values into the message and return
36
        return strtr($message, $replace);
37
    }
38
}