Code Duplication    Length = 22-24 lines in 4 locations

examples/Metrica/Management/filters.php 1 location

@@ 14-37 (lines=24) @@
11
$counterId = null;
12
13
//Is auth
14
if (isset($_COOKIE['yaAccessToken']) && isset($_COOKIE['yaClientId'])) {
15
    $settings = require_once '../../settings.php';
16
17
    try {
18
        $managementClient = new ManagementClient($_COOKIE['yaAccessToken']);
19
20
        if (isset($_GET['counter-id']) && $_GET['counter-id']) {
21
            $counterId = $_GET['counter-id'];
22
23
            //GET /management/v1/counter/{counterId}/filters;
24
            /**
25
             * @see http://api.yandex.ru/metrika/doc/beta/management/filters/filters.xml
26
             */
27
            $filters = $managementClient->filters()->getFilters($counterId);
28
        }
29
30
    } catch (\Exception $ex) {
31
        $errorMessage = $ex->getMessage();
32
        if ($errorMessage === 'PlatformNotAllowed') {
33
            $errorMessage .= '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте '
34
                . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' . '">авторизироваться</a> и повторить.</p>';
35
        }
36
    }
37
}
38
?>
39
<!doctype html>
40
<html lang="en-US">

examples/Metrica/Management/goals.php 1 location

@@ 12-33 (lines=22) @@
9
$errorMessage = false;
10
11
//Is auth
12
if (isset($_COOKIE['yaAccessToken']) && isset($_COOKIE['yaClientId'])) {
13
    $settings = require_once '../../settings.php';
14
15
    try {
16
        $managementClient = new ManagementClient($_COOKIE['yaAccessToken']);
17
18
        if (isset($_GET['counter-id']) && $_GET['counter-id']) {
19
            $counterId = $_GET['counter-id'];
20
            //GET /management/v1/counter/{counterId}/goals;
21
            /**
22
             * @see http://api.yandex.ru/metrika/doc/beta/management/goals/goals.xml
23
             */
24
            $goals = $managementClient->goals()->getGoals($counterId);
25
        }
26
    } catch (\Exception $ex) {
27
        $errorMessage = $ex->getMessage();
28
        if ($errorMessage === 'PlatformNotAllowed') {
29
            $errorMessage .= '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте '
30
                . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' . '">авторизироваться</a> и повторить.</p>';
31
        }
32
    }
33
}
34
?>
35
<!doctype html>
36
<html lang="en-US">

examples/Metrica/Management/grants.php 1 location

@@ 14-37 (lines=24) @@
11
$counterId = null;
12
13
//Is auth
14
if (isset($_COOKIE['yaAccessToken']) && isset($_COOKIE['yaClientId'])) {
15
    $settings = require_once '../../settings.php';
16
17
18
    try {
19
        $managementClient = new ManagementClient($_COOKIE['yaAccessToken']);
20
21
        if (isset($_GET['counter-id']) && $_GET['counter-id']) {
22
            $counterId = $_GET['counter-id'];
23
            //GET /management/v1/counter/{counterId}/grants;
24
    
25
            /**
26
             * @see http://api.yandex.ru/metrika/doc/beta/management/grants/grants.xml
27
             */
28
            $grants = $managementClient->grants()->getGrants($counterId);
29
        }
30
    } catch (\Exception $ex) {
31
        $errorMessage = $ex->getMessage();
32
        if ($errorMessage === 'PlatformNotAllowed') {
33
            $errorMessage .= '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте '
34
                . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' . '">авторизироваться</a> и повторить.</p>';
35
        }
36
    }
37
}
38
?>
39
<!doctype html>
40
<html lang="en-US">

examples/Metrica/Management/operations.php 1 location

@@ 14-35 (lines=22) @@
11
$counterId = null;
12
13
//Is auth
14
if (isset($_COOKIE['yaAccessToken']) && isset($_COOKIE['yaClientId'])) {
15
    $settings = require_once '../../settings.php';
16
17
    try {
18
        $managementClient = new ManagementClient($_COOKIE['yaAccessToken']);
19
20
        if (isset($_GET['counter-id']) && $_GET['counter-id']) {
21
            $counterId = $_GET['counter-id'];
22
            //GET /management/v1/counter/{counterId}/operations;
23
            /**
24
             * @see http://api.yandex.ru/metrika/doc/beta/management/operations/operations.xml
25
             */
26
            $operations = $managementClient->operations()->getOperations($counterId);
27
        }
28
    } catch (\Exception $ex) {
29
        $errorMessage = $ex->getMessage();
30
        if ($errorMessage === 'PlatformNotAllowed') {
31
            $errorMessage .= '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте '
32
                . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' . '">авторизироваться</a> и повторить.</p>';
33
        }
34
    }
35
}
36
?>
37
<!doctype html>
38
<html lang="en-US">