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

mixerapi / mixerapi-dev / 7944560910

17 Feb 2024 10:08PM UTC coverage: 87.512% (-8.3%) from 95.793%
7944560910

Pull #141

github

web-flow
Merge 948144447 into 39576a822
Pull Request #141: MixerAPI v2.0.0 - CakePHP 5 support

36 of 54 new or added lines in 15 files covered. (66.67%)

71 existing lines in 5 files now uncovered.

890 of 1017 relevant lines covered (87.51%)

4.22 hits per line

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

92.31
/plugins/json-ld-view/src/Controller/Component/JsonLdContextComponent.php
1
<?php
2
declare(strict_types=1);
3

4
namespace MixerApi\JsonLdView\Controller\Component;
5

6
use Cake\Controller\Component;
7
use Cake\Core\Configure;
8
use Cake\ORM\Locator\LocatorAwareTrait;
9
use MixerApi\Core\Model\ModelFactory;
10
use MixerApi\JsonLdView\JsonLdEntityContext;
11

12
/**
13
 * Builds JSON-LD context for the given entity.
14
 *
15
 * @link https://json-ld.org/learn.html
16
 */
17
class JsonLdContextComponent extends Component
18
{
19
    use LocatorAwareTrait;
20

21
    /**
22
     * Returns the entity in JSON-LD form as an array
23
     *
24
     * @param string $tableAlias The Table alias
25
     * @return array
26
     */
27
    public function build(string $tableAlias): array
28
    {
29
        $config = Configure::read('JsonLdView');
2✔
30
        if (!empty($config['vocabUrl'])) {
2✔
31
            $data['@vocab'] = $config['vocabUrl'];
2✔
32
        }
33
        if ($config['isHydra']) {
2✔
NEW
34
            $data['hydra'] = 'http://www.w3.org/ns/hydra/core#';
×
35
        }
36

37
        $table = $this->getTableLocator()->get($tableAlias);
2✔
38
        $model = (new ModelFactory($table->getConnection(), $table))->create();
2✔
39

40
        return [
2✔
41
            '@context' => array_merge(
2✔
42
                $data ?? [],
2✔
43
                (new JsonLdEntityContext($model))->build()
2✔
44
            ),
2✔
45
        ];
2✔
46
    }
47
}
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