Mapper.php 1.49 KB
Newer Older
Telman Mazhlumov's avatar
Telman Mazhlumov committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?php


namespace Defa\BxDal\Base;

/**
 * TODO: refactor (нужно, чтобы каждый тип обрабатывался в своем обработчике)
 *
 * Class Mapper
 * @package Defa\BxDal\Base
 */
abstract class Mapper
{
    /**
     *
     */
    const PROPERTY_EXIST = false;

    /**
     *
     */
22
    const FIELD_TYPE_CONVERT_HANDLERS = [];
Telman Mazhlumov's avatar
Telman Mazhlumov committed
23 24 25 26

    /**
     *
     */
27
    const PROP_TYPE_MAPPER_HANDLERS = [];
Telman Mazhlumov's avatar
Telman Mazhlumov committed
28 29 30 31 32 33 34 35 36 37 38 39

    /**
     *
     */
    const PROP_PREFIX = '';

    /**
     *
     */
    const PROP_INNER_PREFIX = '';

    /**
40
     * @param string $attributeName
Telman Mazhlumov's avatar
Telman Mazhlumov committed
41 42
     * @return string
     */
43
    abstract public static function convertAttributeToBx(string $attributeName): string;
Telman Mazhlumov's avatar
Telman Mazhlumov committed
44 45

    /**
46 47 48 49 50 51 52 53
     * @param $values
     * @return mixed
     */
    abstract public static function convertAttributeValuesToBx(array $values): array;

    /**
     * @param $values
     * @return mixed
Telman Mazhlumov's avatar
Telman Mazhlumov committed
54
     */
55
    abstract public static function convertAttributeValuesFromBx(array $values): array;
Telman Mazhlumov's avatar
Telman Mazhlumov committed
56 57

    /**
58
     * @param string $code
Telman Mazhlumov's avatar
Telman Mazhlumov committed
59 60 61
     * @param $value
     * @return mixed
     */
62
    abstract protected static function processField(string $code, $value);
Telman Mazhlumov's avatar
Telman Mazhlumov committed
63 64 65 66 67

    /**
     * @param $value
     * @return mixed
     */
68
    abstract protected static function processProp($value);
Telman Mazhlumov's avatar
Telman Mazhlumov committed
69 70 71 72 73

    /**
     * @param $value
     * @return mixed
     */
74
    abstract protected static function isProperty($value): bool;
Telman Mazhlumov's avatar
Telman Mazhlumov committed
75 76 77 78 79

    /**
     * @param $value
     * @return mixed
     */
80
    abstract protected static function isMultiple($value): bool;
Telman Mazhlumov's avatar
Telman Mazhlumov committed
81
}