Completed
Push — master ( c332a7...d97910 )
by Adeniyi
07:05 queued 02:31
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
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) {
0 ignored issues
show
Bug introduced by
The method all() does not seem to exist on object<Ibonly\PotatoORM\GetData>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
            return $key->$name;
30
        }
31
   }
32
33
   public function getCount()
34
   {
35
        return sizeof($this->value);
36
   }
37
}