MetadataTrait::getMetadataReader()
last analyzed

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
c 0
b 0
f 0
nc 2
nop 1
1
<?php
2
3
namespace Jaxon\Di\Traits;
4
5
use Jaxon\App\Metadata\InputDataInterface;
6
use Jaxon\App\Metadata\MetadataInterface;
7
use Jaxon\App\Metadata\MetadataReaderInterface;
8
9
trait MetadataTrait
10
{
11
    /**
12
     * Register the values into the container
13
     *
14
     * @return void
15
     */
16
    private function registerMetadataReader()
17
    {
18
        // By default, register a fake metadata reader.
19
        $this->set('metadata_reader_null', function() {
0 ignored issues
show
Bug introduced by
It seems like set() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $this->/** @scrutinizer ignore-call */ 
20
               set('metadata_reader_null', function() {
Loading history...
20
            return new class implements MetadataReaderInterface
21
            {
22
                public function getAttributes(InputDataInterface $xInputData): ?MetadataInterface
23
                {
24
                    return null;
25
                }
26
            };
27
        });
28
    }
29
30
    /**
31
     * Get the metadata reader with the given id
32
     *
33
     * @param string $sReaderId
34
     *
35
     * @return MetadataReaderInterface
36
     */
37
    public function getMetadataReader(string $sReaderId): MetadataReaderInterface
38
    {
39
        return $this->h("metadata_reader_$sReaderId") ?
0 ignored issues
show
Bug introduced by
It seems like h() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        return $this->/** @scrutinizer ignore-call */ h("metadata_reader_$sReaderId") ?
Loading history...
40
            $this->g("metadata_reader_$sReaderId") :
0 ignored issues
show
Bug introduced by
It seems like g() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
            $this->/** @scrutinizer ignore-call */ 
41
                   g("metadata_reader_$sReaderId") :
Loading history...
41
            $this->g('metadata_reader_null');
42
    }
43
}
44