Passed
Push — master ( 0076ce...72e11f )
by Richard
10:31 queued 15s
created

HasMeta::meta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Riclep\Storyblok\Traits;
5
6
7
trait HasMeta
8
{
9
	/**
10
	 * @var array stores the meta items for this class
11
	 */
12
	protected $_meta = [];
13
14
	/**
15
	 * Returns the meta items
16
	 *
17
	 * @return array
18
	 */
19
	public function meta() {
20
		// TODO return single key - with default
21
		return $this->_meta;
22
	}
23
24
	/**
25
	 * Adds a meta item
26
	 *
27
	 * @param $fields
28
	 */
29
	public function addMeta($fields) {
30
		$this->_meta = array_merge($this->_meta, $fields);
31
	}
32
33
	/**
34
	 * Replaces a meta item
35
	 *
36
	 * @param $key
37
	 * @param $value
38
	 */
39
	public function replaceMeta($key, $value) {
40
		$this->_meta[$key] = $value;
41
	}
42
}