InterfaceModel::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace carono\exchange1c\models;
5
6
7
use carono\exchange1c\helpers\ClassHelper;
8
use yii\base\Model;
9
use yii\helpers\ArrayHelper;
10
use yii\helpers\Html;
11
12
/**
13
 * @property integer status_id
14
 * @property string status_name
15
 */
16
class InterfaceModel extends Model
17
{
18
    const STATUS_UNKNOWN = -1;
19
    const STATUS_METHOD_NOT_FOUND = 1;
20
    public static $statuses = [
21
        self::STATUS_METHOD_NOT_FOUND => 'Метод не найден'
22
    ];
23
    public $function;
24
    public $interface;
25
    public $class;
26
27
    public function getStatus_id()
28
    {
29
        if (!$this->functionExists()) {
30
            return self::STATUS_METHOD_NOT_FOUND;
31
        }
32
        return self::STATUS_UNKNOWN;
33
    }
34
35
    public function getStatus_name()
36
    {
37
        return ArrayHelper::getValue(self::$statuses, $this->status_id, $this->status_id);
38
    }
39
40
    public function functionExists()
41
    {
42
        return array_search($this->function, ClassHelper::getMethods($this->class)) !== false;
43
    }
44
45
    public function getDescription()
46
    {
47
        $method = new \ReflectionMethod($this->interface, $this->function);
48
        return nl2br(preg_replace('#\*/|/\*|\*#', '', $method->getDocComment()));
49
    }
50
}