showErrors()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
include './cloudflare/CloudflareConnection.php';
4
include 'TestVariables.php';
5
6
$error_emoticon = '⚠️';
7
$success_emotion = '☑️';
8
9
$cc = new CloudflareConnection($username, $api_key);
10
11
$user = $cc->currentUser();
12
echo($user['success'] !== true ? $error_emoticon : $success_emotion)."️ Get current user\n";
13
showErrors($user['errors']);
14
15
$zones = $cc->getZones([]);
16
echo($zones['success'] !== true ? $error_emoticon : $success_emotion)." Get zones\n";
17
showErrors($zones['errors']);
18
19
$dns_records = $cc->getDnsRecordsForZone($zones['result'][0]['id'], []);
20
echo($dns_records['success'] !== true ? $error_emoticon : $success_emotion)." Get DNS records\n";
21
showErrors($dns_records['errors']);
22
23
$zone_created = $cc->createZone($test_domain_creation_on, $account_id);
24
echo($zone_created['success'] !== true ? $error_emoticon : $success_emotion)." Create Zone\n";
25
showErrors($zone_created['errors']);
26
27
if ($zone_created['success']) {
28
    $zone_deleted = $cc->deleteZone($zone_created['result']['id']);
29
    echo($zone_deleted['success'] !== true ? $error_emoticon : $success_emotion)." Delete Zone\n";
30
    showErrors($zone_deleted['errors']);
31
}
32
33
function showErrors(array $errors)
34
{
35
    foreach ($errors as $error) {
36
        echo '* '.$error['code'].' : '.$error['message']."\r\n";
37
    }
38
}
39