• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlocati / nexi / 8553199573

04 Apr 2024 10:31AM UTC coverage: 2.945% (-0.06%) from 3.004%
8553199573

push

github

mlocati
Add test cards

0 of 34 new or added lines in 2 files covered. (0.0%)

51 of 1732 relevant lines covered (2.94%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Dictionary/TestCard.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace MLocati\Nexi\Dictionary;
6

7
use MLocati\Nexi\Dictionary\TestCard\Card;
8

9
/*
10
 * WARNING: DO NOT EDIT THIS FILE
11
 * It has been generated automaticlly from a template.
12
 * Edit the template instead.
13
 */
14

15
/**
16
 * List of cards that can be used for tests.
17
 *
18
 * @see https://developer.nexi.it/en/area-test/carte-di-pagamento
19
 */
20
class TestCard
21
{
22
    /**
23
     * @var \MLocati\Nexi\Dictionary\TestCard\Card[]
24
     */
25
    private $cards;
26

27
    public function __construct()
28
    {
NEW
29
        $this->cards = [
×
NEW
30
            new Card(true, 'VISA', '4349940199004549', 5, 26, '396'),
×
NEW
31
            new Card(true, 'MASTERCARD', '5186151650005008', 12, 26, '123'),
×
NEW
32
            new Card(false, 'VISA', '4349940199997007', 12, 28, '829'),
×
NEW
33
            new Card(false, 'MASTERCARD', '5533893874304465', 12, 28, '123'),
×
34
        ];
NEW
35
    }
×
36

37
    /**
38
     * Get the available circuits.
39
     *
40
     * @param bool|null $positiveOutcome set to true to list circuits for which we have cards with positive outcomes, false for negative outcomes, NULL for any outcome
41
     * @return string[]
42
     */
43
    public function getAvailableCircuits(?bool $positiveOutcome = null): array
44
    {
NEW
45
        $circuits = [];
×
NEW
46
        foreach ($this->cards as $card) {
×
NEW
47
            if ($positiveOutcome === null || $card->isPositiveOutcome() === $positiveOutcome) {
×
NEW
48
                $circuits[] = $card->getCircuit();
×
49
            }
50
        }
51

NEW
52
        $circuits = array_unique($circuits);
×
NEW
53
        sort($circuits, SORT_STRING);
×
54

NEW
55
        return array_values($circuits);
×
56
    }
57

58
    public function getSampleCard(bool $positiveOutcome, string $circuit): ?Card
59
    {
NEW
60
        $cards = array_filter(
×
NEW
61
            $this->cards,
×
62
            static function (Card $card) use ($positiveOutcome, $circuit): bool {
NEW
63
                return $card->isPositiveOutcome() === $positiveOutcome && $card->getCircuit() === $circuit;
×
NEW
64
            }
×
65
        );
66

NEW
67
        return array_shift($cards);
×
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc