TestingProductClass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getContext() 0 4 1
A methodRules() 0 24 1
A getResultCreateModel1c() 0 6 1
1
<?php
2
3
4
namespace carono\exchange1c\models;
5
6
use carono\exchange1c\interfaces\GroupInterface;
7
use carono\exchange1c\interfaces\OfferInterface;
8
use carono\exchange1c\interfaces\ProductInterface;
9
10
/**
11
 * Class TestingProductClass
12
 *
13
 * @package carono\exchange1c\models
14
 * @method static ProductInterface getPropertyClass()
15
 */
16
class TestingProductClass extends TestingClass
17
{
18
    protected static $property = 'productClass';
19
20
    public static function getContext()
21
    {
22
        $class = self::getPropertyClass();
23
        return call_user_func_array("$class::createModel1c", self::getParams(['cml.catalog.products.0']));
24
    }
25
26
    public function getResultCreateModel1c()
27
    {
28
        $params = self::getParams(['cml.catalog.products.0']);
29
        self::getMethodResult('createModel1c', ['cml.catalog.products.0']);
30
        $class = self::getPropertyClass();
31
        return $class::findOne([$class::getIdFieldName1c() => $params[0]->id]);
32
    }
33
34
    public static function methodRules()
35
    {
36
        return [
37
            'getIdFieldName1c' => [
38
                'return' => self::RETURN_STRING,
39
                'auto' => true
40
            ],
41
            'createModel1c' => [
42
                'return' => self::RETURN_INTERFACE,
43
                'value' => ProductInterface::class,
44
                'params' => ['cml.catalog.products.0']
45
            ],
46
            'getOffer1c' => [
47
                'return' => self::RETURN_INTERFACE,
48
                'value' => OfferInterface::class,
49
                'params' => ['cml.offerPackage.offers.0']
50
            ],
51
            'setGroup1c' => [
52
                'return' => false,
53
                'params' => ['cml.catalog.products.0.group']
54
            ],
55
            'getGroup1c' => [
56
                'return' => self::RETURN_INTERFACE,
57
                'value' => GroupInterface::class
58
            ]
59
        ];
60
    }
61
}