Completed
Pull Request — master (#17)
by Adeniyi
03:27
created

GetData::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Ibonly\PotatoORM;
4
5
use Ibonly\PotatoORM\GetDataInterface;
6
7
class GetData implements GetDataInterface
0 ignored issues
show
Bug introduced by
There is one abstract method all in this class; you could implement it, or declare this class as abstract.
Loading history...
8
{
9
    protected $value;
10
11
    function __construct($value)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
12
    {
13
        $this->value = $value;
14
    }
15
16
    public function toArray()
17
    {
18
        return $this->value;
19
    }
20
21
    public function toJson()
22
    {
23
        return json_encode($this->value);
24
    }
25
26
    public function getData($name)
27
    {
28
        foreach (json_decode($this->all()) as $key) {
29
            return $key->$name;
30
        }
31
   }
32
33
   public function getCount()
34
   {
35
        return sizeof($this->value);
36
   }
37
}