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

GetData   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 31
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 4 1
A toJson() 0 4 1
A getData() 0 6 2
A getCount() 0 4 1
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
}