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

acdh-oeaw / arche-diss-cache / #57

24 Oct 2024 10:11PM UTC coverage: 80.841%. Remained the same
#57

push

php-coveralls

zozlak
Service::setCallback() introduced

6 of 6 new or added lines in 1 file covered. (100.0%)

173 of 214 relevant lines covered (80.84%)

3.22 hits per line

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

93.75
/src/acdhOeaw/arche/lib/dissCache/RepoResourceCacheItem.php
1
<?php
2

3
/*
4
 * The MIT License
5
 *
6
 * Copyright 2024 zozlak.
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26

27
namespace acdhOeaw\arche\lib\dissCache;
28

29
use quickRdf\Dataset;
30
use quickRdf\DatasetNode;
31
use quickRdf\DataFactory;
32
use quickRdfIo\NQuadsParser;
33
use quickRdfIo\NQuadsSerializer;
34
use acdhOeaw\arche\lib\RepoInterface;
35
use acdhOeaw\arche\lib\RepoResourceInterface;
36
use acdhOeaw\arche\lib\RepoResourceTrait;
37

38
/**
39
 * 
40
 *
41
 * @author zozlak
42
 */
43
class RepoResourceCacheItem implements RepoResourceInterface {
44

45
    use RepoResourceTrait;
46

47
    static private NQuadsParser $parser;
48
    static private NQuadsSerializer $serializer;
49

50
    static public function serialize(RepoResourceInterface $res): string {
51
        self::$serializer ??= new NQuadsSerializer();
8✔
52
        $data             = [
8✔
53
            'uri'      => (string) $res->getUri(),
8✔
54
            'metadata' => self::$serializer->serialize($res->getGraph()->getDataset()),
8✔
55
        ];
8✔
56
        return (string) json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
8✔
57
    }
58

59
    static public function deserialize(string $data): self {
60
        self::$parser ??= new NQuadsParser(new DataFactory(), false, NQuadsParser::MODE_TRIPLES);
4✔
61

62
        $data  = json_decode($data);
4✔
63
        $graph = new Dataset();
4✔
64
        $graph->add(self::$parser->parse($data->metadata));
4✔
65
        $res   = new self($data->uri, null);
4✔
66
        $res->setGraph($graph);
4✔
67
        return $res;
4✔
68
    }
69

70
    /* @phpstan-ignore constructor.unusedParameter */
71
    public function __construct(string $url, ?RepoInterface $repo) {
72
        $this->metadata = new DatasetNode(DataFactory::namedNode($url));
4✔
73
    }
74

75
    public function loadMetadata(bool $force = false,
76
                                 string $mode = self::META_RESOURCE,
77
                                 ?string $parentProperty = null,
78
                                 array $resourceProperties = [],
79
                                 array $relativesProperties = []): void {
80
        if (count($this->metadata) === 0 || $force) {
3✔
81
            throw new \BadMethodCallException("Not implemented");
×
82
        }
83
    }
84
}
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