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

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

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

0.0
/src/Elasticsearch/Metadata/Document/Factory/ConfiguredDocumentMetadataFactory.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Elasticsearch\Metadata\Document\Factory;
15

16
use ApiPlatform\Elasticsearch\Exception\IndexNotFoundException;
17
use ApiPlatform\Elasticsearch\Metadata\Document\DocumentMetadata;
18

19
/**
20
 * Creates document's metadata using the mapping configuration.
21
 *
22
 * @deprecated
23
 *
24
 * @author Baptiste Meyer <baptiste.meyer@gmail.com>
25
 */
26
final class ConfiguredDocumentMetadataFactory implements DocumentMetadataFactoryInterface
27
{
28
    public function __construct(private readonly array $mapping, private readonly ?DocumentMetadataFactoryInterface $decorated = null)
29
    {
30
    }
×
31

32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function create(string $resourceClass): DocumentMetadata
36
    {
37
        $documentMetadata = null;
×
38

39
        if ($this->decorated) {
×
40
            try {
41
                $documentMetadata = $this->decorated->create($resourceClass);
×
42
            } catch (IndexNotFoundException) {
×
43
            }
44
        }
45

46
        if (null === $index = $this->mapping[$resourceClass] ?? null) {
×
47
            if ($documentMetadata) {
×
48
                return $documentMetadata;
×
49
            }
50

51
            throw new IndexNotFoundException(sprintf('No index associated with the "%s" resource class.', $resourceClass));
×
52
        }
53

54
        $documentMetadata ??= new DocumentMetadata();
×
55

56
        if (isset($index['index'])) {
×
57
            $documentMetadata = $documentMetadata->withIndex($index['index']);
×
58
        }
59

60
        if (isset($index['type'])) {
×
61
            $documentMetadata = $documentMetadata->withType($index['type']);
×
62
        }
63

64
        return $documentMetadata;
×
65
    }
66
}
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