Passed
Push — master ( 5b5c00...4c0c12 )
by Julien
04:52
created

CountAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A countAction() 0 9 2
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Controller\Rest\Actions;
13
14
use Exception;
15
use Phalcon\Http\ResponseInterface;
16
use Zemit\Mvc\Controller\AbstractTrait\AbstractInjectable;
17
use Zemit\Mvc\Controller\Rest\Response;
18
19
trait CountAction
20
{
21
    use AbstractInjectable;
22
    use Response;
23
    
24
    /**
25
     * Count a record list
26
     * Will use the getFind query
27
     * @throws Exception
28
     */
29
    public function countAction(): ResponseInterface
30
    {
31
        $model = $this->getModelClassName();
0 ignored issues
show
Bug introduced by
It seems like getModelClassName() 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

31
        /** @scrutinizer ignore-call */ 
32
        $model = $this->getModelClassName();
Loading history...
32
        
33
        $countResult = $model::count($this->getFindCount($this->getFind()));
0 ignored issues
show
Bug introduced by
It seems like getFind() 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

33
        $countResult = $model::count($this->getFindCount($this->/** @scrutinizer ignore-call */ getFind()));
Loading history...
Bug introduced by
It seems like getFindCount() 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

33
        $countResult = $model::count($this->/** @scrutinizer ignore-call */ getFindCount($this->getFind()));
Loading history...
34
        $count = is_array($countResult) ? count($countResult) : $countResult;
35
        
36
        $this->view->setVar('count', $count);
0 ignored issues
show
Bug introduced by
The property view does not exist on Zemit\Mvc\Controller\Rest\Actions\CountAction. Did you mean view;?
Loading history...
37
        return $this->setRestResponse(true);
38
    }
39
}
40