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

diego-ninja / granite / 16608963009

29 Jul 2025 10:37PM UTC coverage: 50.423%. First build
16608963009

Pull #5

github

web-flow
Merge 43d8840d7 into 6a6caca51
Pull Request #5: code: adds phpstan level max, pint with per and github actions

321 of 632 new or added lines in 77 files covered. (50.79%)

1132 of 2245 relevant lines covered (50.42%)

9.88 hits per line

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

44.44
/src/Mapping/Cache/CacheFactory.php
1
<?php
2

3
namespace Ninja\Granite\Mapping\Cache;
4

5
use Ninja\Granite\Enums\CacheType;
6
use Ninja\Granite\Mapping\Contracts\MappingCache;
7

8
/**
9
 * Factory for creating mapping caches.
10
 */
11
class CacheFactory
12
{
13
    /**
14
     * Cache directory for persistent caches.
15
     */
16
    private static string $cacheDir = '';
17

18
    /**
19
     * Create a mapping cache based on environment.
20
     *
21
     * @param CacheType $type Cache type ('memory', 'shared', 'persistent')
22
     * @return MappingCache Mapping cache
23
     */
24
    public static function create(CacheType $type = CacheType::Memory): MappingCache
10✔
25
    {
26
        return match ($type) {
27
            CacheType::Shared => SharedMappingCache::getInstance(),
10✔
28
            CacheType::Persistent => new PersistentMappingCache(self::getCachePath()),
10✔
29
            default => new InMemoryMappingCache(),
10✔
30
        };
31
    }
32

33
    /**
34
     * Set cache directory.
35
     *
36
     * @param string $dir Cache directory
37
     * @return void
38
     */
39
    public static function setCacheDirectory(string $dir): void
×
40
    {
NEW
41
        self::$cacheDir = mb_rtrim($dir, '/\\');
×
42
    }
43

44
    /**
45
     * Get cache file path.
46
     *
47
     * @return string Cache file path
48
     */
49
    private static function getCachePath(): string
×
50
    {
51
        $dir = self::$cacheDir ?: sys_get_temp_dir();
×
52
        return $dir . '/granite_mapper_cache.php';
×
53
    }
54
}
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