Completed
Push — master ( fa5230...195b94 )
by Mohamed
16:12 queued 06:12
created

DataMappingTrait::toArrayCallback()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 2 Features 0
Metric Value
c 3
b 2
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
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
namespace Tinyissue\Model\Traits\Tag;
13
14
use Tinyissue\Model\Tag;
15
16
/**
17
 * DataMappingTrait is trait class containing methods to manipulate the data of the Tag model.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 */
21
trait DataMappingTrait
22
{
23
    /**
24
     * Callback to return tag details for JS library tokenfield.
25
     *
26
     * @param Tag $tag
27
     *
28
     * @return array
29
     */
30
    public function tokenFieldCallback(Tag $tag)
31
    {
32
        return array_combine([
33
            'value',
34
            'label',
35
            'bgcolor',
36
        ], $this->toArray($tag));
0 ignored issues
show
Bug introduced by
The method toArray() does not exist on Tinyissue\Model\Traits\Tag\DataMappingTrait. Did you maybe mean toArrayCallback()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
37
    }
38
39
    /**
40
     * Callback to return tag details as array.
41
     *
42
     * @param Tag $tag
43
     *
44
     * @return array
45
     */
46
    public function toArrayCallback(Tag $tag)
47
    {
48
        return [
49
            'id'      => $tag->id,
50
            'name'    => $tag->fullname,
51
            'bgcolor' => $tag->bgcolor,
52
        ];
53
    }
54
}
55