Completed
Push — master ( 38ffd4...ed5eea )
by Evan
03:02
created

TypeMeta::meta()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
rs 9.4285
1
<?php
2
3
namespace Silk\Meta;
4
5
trait TypeMeta
6
{
7
    /**
8
     * Meta API for this type
9
     *
10
     * @param  string $key  Meta key to retreive or empty to retreive all.
11
     *
12
     * @return object
13
     */
14
    public function meta($key = '')
15
    {
16
        $meta = new ObjectMeta(static::OBJECT_TYPE, $this->id);
0 ignored issues
show
Bug introduced by
The property id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
18
        if ($key) {
19
            return $meta->get($key);
20
        }
21
22
        return $meta;
23
    }
24
}
25