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

mlocati / PayWay / 5212705470

pending completion
5212705470

push

github

mlocati
Initial version

1803 of 1803 new or added lines in 47 files covered. (100.0%)

1313 of 1803 relevant lines covered (72.82%)

1.53 hits per line

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

50.0
/src/Service/Dictionary.php
1
<?php
2

3
namespace MLocati\PayWay\Service;
4

5
use RuntimeException;
6

7
abstract class Dictionary
8
{
9
    /**
10
     * @return array
11
     */
12
    public static function getDictionary()
13
    {
14
        if (static::$dictionary === null) {
4✔
15
            $dictionary = include __DIR__ . '/../data/' . static::getDictionaryFile();
2✔
16
            if (!is_array($dictionary)) {
2✔
17
                throw new RuntimeException('Failed to retrieve the dictionary');
×
18
            }
19
            static::$dictionary = $dictionary;
2✔
20
        }
21

22
        return static::$dictionary;
4✔
23
    }
24

25
    /**
26
     * @param string|mixed $code
27
     *
28
     * @return string Empty string if $code is not valid
29
     */
30
    public static function getName($code)
31
    {
32
        if (!is_string($code) || $code === '') {
×
33
            return '';
×
34
        }
35
        $dictionary = static::getDictionary();
×
36

37
        return isset($dictionary[$code]) ? $dictionary[$code] : '';
×
38
    }
39

40
    /**
41
     * @param string|mixed $code
42
     *
43
     * @return bool
44
     */
45
    public static function isCodeValid($code)
46
    {
47
        return static::getName($code) !== '';
×
48
    }
49

50
    /**
51
     * @return string[]
52
     */
53
    public static function getAvailableCodes()
54
    {
55
        return array_keys(static::getDictionary());
4✔
56
    }
57
}
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

© 2025 Coveralls, Inc