Passed
Push — master ( 420639...4ea9f2 )
by Andreas
11:06
created

midgard_admin_asgard_handler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 28
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_response() 0 10 3
A load_deleted() 0 14 1
1
<?php
2
/**
3
 * @package midgard.admin.asgard
4
 * @author CONTENT CONTROL http://www.contentcontrol-berlin.de/
5
 * @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/
6
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
7
 */
8
9
use midgard\portable\storage\connection;
10
11
/**
12
 * @package midgard.admin.asgard
13
 */
14
trait midgard_admin_asgard_handler
15
{
16 40
    public function get_response(string $element = null) : midcom_response_styled
17
    {
18 40
        if (isset($_GET['ajax'])) {
19
            midcom::get()->skip_page_style = true;
20
        }
21 40
        $this->populate_breadcrumb_line();
0 ignored issues
show
Bug introduced by
It seems like populate_breadcrumb_line() 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
               populate_breadcrumb_line();
Loading history...
22 40
        if ($element) {
23 26
            return $this->show($element, 'ASGARD_ROOT');
0 ignored issues
show
Bug introduced by
It seems like show() 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
            return $this->/** @scrutinizer ignore-call */ show($element, 'ASGARD_ROOT');
Loading history...
24
        }
25 14
        return new midcom_response_styled(midcom_core_context::get(), 'ASGARD_ROOT');
26
    }
27
28 1
    public function load_deleted(string $guid) : midcom_core_dbaobject
29
    {
30 1
        $type = connection::get_em()
31 1
            ->createQuery('SELECT r.typename from midgard_repligard r WHERE r.guid = ?1')
32 1
            ->setParameter(1, $guid)
33 1
            ->getSingleScalarResult();
34
35 1
        $dba_type = midcom::get()->dbclassloader->get_midcom_class_name_for_mgdschema_object($type);
36
37 1
        $qb = midcom::get()->dbfactory->new_query_builder($dba_type);
0 ignored issues
show
Bug introduced by
It seems like $dba_type can also be of type null; however, parameter $classname of midcom_helper__dbfactory::new_query_builder() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

37
        $qb = midcom::get()->dbfactory->new_query_builder(/** @scrutinizer ignore-type */ $dba_type);
Loading history...
38 1
        $qb->include_deleted();
39 1
        $qb->add_constraint('guid', '=', $guid);
40
41 1
        return $qb->get_result(0);
42
    }
43
}
44