Issues (59)

src/Actions/Getter.php (7 issues)

1
<?php
2
/**
3
 * Get data
4
 * User: moyo
5
 * Date: 22/12/2017
6
 * Time: 4:45 PM
7
 */
8
9
namespace Carno\Database\SQL\Actions;
10
11
use Carno\Database\Results\Selected;
12
use Carno\Database\SQL\Action;
13
14
trait Getter
15
{
16
    /**
17
     * @return array
18
     */
19
    public function get()
20
    {
21
        $this->actTrigger(Action::SELECT, $this);
0 ignored issues
show
It seems like actTrigger() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        $this->/** @scrutinizer ignore-call */ 
22
               actTrigger(Action::SELECT, $this);
Loading history...
22
23
        $this->limit(1);
0 ignored issues
show
It seems like limit() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        $this->/** @scrutinizer ignore-call */ 
24
               limit(1);
Loading history...
24
25
        /**
26
         * @var Selected $rows
27
         */
28
        $rows = yield $this->exec($this->sql(Action::SELECT));
0 ignored issues
show
Bug Best Practice introduced by
The expression yield $this->exec($this-...se\SQL\Action::SELECT)) returns the type Generator which is incompatible with the documented return type array.
Loading history...
It seems like sql() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $rows = yield $this->exec($this->/** @scrutinizer ignore-call */ sql(Action::SELECT));
Loading history...
It seems like exec() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $rows = yield $this->/** @scrutinizer ignore-call */ exec($this->sql(Action::SELECT));
Loading history...
29
        if ($rows->count() > 0) {
30
            return (yield $this->rsTrigger((array)$rows))[0];
0 ignored issues
show
It seems like rsTrigger() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
            return (yield $this->/** @scrutinizer ignore-call */ rsTrigger((array)$rows))[0];
Loading history...
31
        }
32
33
        return [];
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function list()
40
    {
41
        $this->actTrigger(Action::SELECT, $this);
42
43
        /**
44
         * @var Selected $rows
45
         */
46
        $rows = yield $this->exec($this->sql(Action::SELECT));
0 ignored issues
show
Bug Best Practice introduced by
The expression yield $this->exec($this-...se\SQL\Action::SELECT)) returns the type Generator which is incompatible with the documented return type array.
Loading history...
47
        if ($rows->count() > 0) {
48
            return yield $this->rsTrigger((array)$rows);
49
        }
50
51
        return [];
52
    }
53
}
54