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

mattiabasone / minepic / 4098783173

pending completion
4098783173

push

github

GitHub
Remove swoole and upgrade dependencies (#20)

738 of 864 relevant lines covered (85.42%)

4.89 hits per line

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

50.0
/app/Helpers/Storage/Storage.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Minepic\Helpers\Storage;
6

7
use Minepic\Minecraft\MinecraftDefaults;
8

9
class Storage
10
{
11
    /**
12
     * Storage folder type.
13
     *
14
     * @var string
15
     */
16
    protected static string $folder;
17

18
    /**
19
     * Skin Path.
20
     *
21
     * @param string $uuid
22
     *
23
     * @throws \Exception
24
     *
25
     * @return string
26
     */
27
    public static function getPath(string $uuid): string
28
    {
29
        if ($uuid === '') {
17✔
30
            $uuid = MinecraftDefaults::getRandomDefaultSkin();
×
31
        }
32

33
        return sprintf(storage_path(static::$folder.'/%s.png'), $uuid);
17✔
34
    }
35

36
    /**
37
     * Checks if file exists.
38
     *
39
     * @param string $uuid
40
     *
41
     * @return bool
42
     */
43
    public static function exists(string $uuid): bool
44
    {
45
        return file_exists(static::getPath($uuid));
12✔
46
    }
47

48
    /**
49
     * Save the skin to file.
50
     *
51
     * @param string $uuid
52
     * @param mixed  $rawData
53
     *
54
     * @return bool
55
     */
56
    public static function save(string $uuid, $rawData): bool
57
    {
58
        $fp = fopen(static::getPath($uuid), 'wb');
2✔
59
        if (\is_resource($fp)) {
2✔
60
            fwrite($fp, $rawData);
2✔
61
            fclose($fp);
2✔
62

63
            return true;
2✔
64
        }
65

66
        return false;
×
67
    }
68

69
    /**
70
     * Use Steve file for given uuid.
71
     *
72
     * @param string $name
73
     * @throws \Exception
74
     * @return bool
75
     */
76
    public static function copyAsSteve(string $name): bool
77
    {
78
        if ($name !== '') {
×
79
            return copy(
×
80
                static::getPath(MinecraftDefaults::getRandomDefaultSkin()),
×
81
                static::getPath($name)
×
82
            );
×
83
        }
84

85
        return false;
×
86
    }
87
}
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