Code Duplication    Length = 21-21 lines in 2 locations

src/TelegramLog.php 2 locations

@@ 121-141 (lines=21) @@
118
     *
119
     * @deprecated Initialise a preconfigured logger instance instead.
120
     */
121
    public static function initErrorLog($path)
122
    {
123
        (defined('PHPUNIT_TESTSUITE') && PHPUNIT_TESTSUITE) || trigger_error(__METHOD__ . ' is deprecated and will be removed soon. Initialise with a preconfigured logger instance instead using "TelegramLog::initialize($logger)".', E_USER_DEPRECATED);
124
125
        if ($path === null || $path === '') {
126
            throw new TelegramLogException('Empty path for error log');
127
        }
128
        self::initialize();
129
130
        // Deprecated code used as fallback.
131
        if (self::$logger instanceof Logger) {
132
            self::$error_log_path = $path;
133
134
            self::$logger->pushHandler(
135
                (new StreamHandler(self::$error_log_path, Logger::ERROR))
136
                    ->setFormatter(new LineFormatter(null, null, true))
137
            );
138
        }
139
140
        return self::$logger;
141
    }
142
143
    /**
144
     * Initialise debug log (deprecated)
@@ 153-173 (lines=21) @@
150
     *
151
     * @deprecated Initialise a preconfigured logger instance instead.
152
     */
153
    public static function initDebugLog($path)
154
    {
155
        (defined('PHPUNIT_TESTSUITE') && PHPUNIT_TESTSUITE) || trigger_error(__METHOD__ . ' is deprecated and will be removed soon. Initialise with a preconfigured logger instance instead using "TelegramLog::initialize($logger)".', E_USER_DEPRECATED);
156
157
        if ($path === null || $path === '') {
158
            throw new TelegramLogException('Empty path for debug log');
159
        }
160
        self::initialize();
161
162
        // Deprecated code used as fallback.
163
        if (self::$logger instanceof Logger) {
164
            self::$debug_log_path = $path;
165
166
            self::$logger->pushHandler(
167
                (new StreamHandler(self::$debug_log_path, Logger::DEBUG))
168
                    ->setFormatter(new LineFormatter(null, null, true))
169
            );
170
        }
171
172
        return self::$logger;
173
    }
174
175
    /**
176
     * Initialise update log (deprecated)