Issues (7)

example/subscription.php (1 issue)

Severity
1
<?php
2
require __DIR__ . "/assets/config.php";
3
require __DIR__ . "/../vendor/autoload.php";
4
5
use CarlosBrito\CafeApi\Subscriptions;
6
7
$subscription = new Subscriptions(
8
    "localhost/fsphp/cafeapi/",
9
    "[email protected]",
10
    "12345678"
11
);
12
13
/**
14
 * index
15
 */
16
echo "<h1>INDEX</h1>";
17
$index = $subscription->index(null);
0 ignored issues
show
The call to CarlosBrito\CafeApi\Subscriptions::index() has too many arguments starting with null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
$index = $subscription->/** @scrutinizer ignore-call */ index(null);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
18
19
if ($index->error()) {
20
    var_dump($index->error());
21
} else {
22
    var_dump($index->response());
23
}
24
25
26
/**
27
 * create
28
 */
29
echo "<h1>CREATE</h1>";
30
31
$create = $subscription->create([
32
    "plan_id" => 1,
33
    "card_number" => "5583983765729729",
34
    "card_holder_name" => "ROBSON LEITE",
35
    "card_expiration_date" => "12/2020",
36
    "card_cvv" => "654"
37
]);
38
39
if ($create->error()) {
40
    echo "<p class='error'>{$create->error()->message}</p>";
41
} else {
42
    var_dump($create->response());
43
}
44
45
/**
46
 * READ
47
 */
48
echo "<h1>READ</h1>";
49
50
$read = $subscription->read();
51
52
if ($read->error()) {
53
    echo "<p class='error'>{$read->error()->message}</p>";
54
} else {
55
    var_dump($read->response());
56
}
57
58
/**
59
 * UPDATE
60
 */
61
echo "<h1>UPDATE</h1>";
62
63
//$update = $subscription->update(["plan_id" => 2]);
64
$update = $subscription->update([
65
    "card_number" => "4024007190034479",
66
    "card_holder_name" => "ROBSON LEITE",
67
    "card_expiration_date" => "12/2020",
68
    "card_cvv" => "654"
69
]);
70
71
if ($update->error()) {
72
    echo "<p class='error'>{$update->error()->message}</p>";
73
} else {
74
    var_dump($update->response());
75
}