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

NewAction   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A newAction() 0 11 1
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 Phalcon\Mvc\ModelInterface;
17
use Zemit\Mvc\Controller\AbstractTrait\AbstractInjectable;
18
19
trait NewAction {
20
    
21
    use AbstractInjectable;
22
    
23
    /**
24
     * Prepare a new unsaved model
25
     * This is useful if you want the default values
26
     * @throws Exception
27
     */
28
    public function newAction(): ResponseInterface
29
    {
30
        $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

30
        /** @scrutinizer ignore-call */ 
31
        $model = $this->getModelClassName();
Loading history...
31
        
32
        $entity = new $model();
33
        assert($entity instanceof ModelInterface);
34
        
35
        $entity->assign($this->getParams(), $this->getWhiteList(), $this->getColumnMap());
0 ignored issues
show
Bug introduced by
It seems like getWhiteList() 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

35
        $entity->assign($this->getParams(), $this->/** @scrutinizer ignore-call */ getWhiteList(), $this->getColumnMap());
Loading history...
Bug introduced by
It seems like getParams() 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

35
        $entity->assign($this->/** @scrutinizer ignore-call */ getParams(), $this->getWhiteList(), $this->getColumnMap());
Loading history...
Bug introduced by
It seems like getColumnMap() 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

35
        $entity->assign($this->getParams(), $this->getWhiteList(), $this->/** @scrutinizer ignore-call */ getColumnMap());
Loading history...
36
        
37
        $this->view->setVar('single', $this->expose($entity));
0 ignored issues
show
Bug introduced by
It seems like expose() 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

37
        $this->view->setVar('single', $this->/** @scrutinizer ignore-call */ expose($entity));
Loading history...
Bug introduced by
The property view does not exist on Zemit\Mvc\Controller\Rest\Actions\NewAction. Did you mean view;?
Loading history...
38
        return $this->setRestResponse(true);
0 ignored issues
show
Bug introduced by
It seems like setRestResponse() 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

38
        return $this->/** @scrutinizer ignore-call */ setRestResponse(true);
Loading history...
39
    }
40
    
41
}
42