Test Failed
Push — master ( fdb79d...2e4512 )
by Chris
19:35
created

AbstractSystemModelTypeRegistrar   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 19
dl 0
loc 27
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseArgs() 0 18 1
A unregisteredOptionException() 0 4 1
1
<?php
2
3
namespace Leonidas\Library\System;
4
5
use Leonidas\Contracts\System\BaseSystemModelTypeInterface;
6
use UnexpectedValueException;
7
8
abstract class AbstractSystemModelTypeRegistrar
9
{
10
    protected function unregisteredOptionException(string $option): UnexpectedValueException
11
    {
12
        return new UnexpectedValueException(
13
            "There is no registered handler for option \"{$option}\" provided."
14
        );
15
    }
16
17
    protected function getBaseArgs(BaseSystemModelTypeInterface $type): array
18
    {
19
        return [
20
            'labels' => $type->getLabels(),
21
            'description' => $type->getDescription(),
22
            'public' => $type->isPublic(),
23
            'hierarchical' => $type->isHierarchical(),
24
            'publicly_queryable' => $type->isPubliclyQueryable(),
25
            'show_ui' => $type->isShownInUi(),
26
            'show_in_menu' => $type->getShownInMenu(),
27
            'show_in_nav_menus' => $type->isShownInNavMenus(),
28
            'capabilities' => $type->getCapabilities(),
29
            'rewrite' => $type->getRewrite(),
30
            'query_var' => $type->getQueryVar(),
31
            'show_in_rest' => $type->isShownInRest(),
32
            'rest_base' => $type->getRestBase(),
33
            'rest_namespace' => $type->getRestNamespace(),
34
            'rest_controller_class' => $type->getRestControllerClass(),
35
        ];
36
    }
37
}
38