Download the PHP package dvasilenko/datamapper_tools without Composer

On this page you can find all versions of the php package dvasilenko/datamapper_tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package datamapper_tools

DataMapper

DataMapper помогает вам преобразовать один формат данные в другой, вы можете получить как массив данных, так и XML.

Содержание

  1. Установка
  2. Использование
    1. Создать свой DataMapper
    2. Настройка своего DataMapper
    3. Создание своего обработчика типа данных
    4. Использование DataMapper
  3. Обработчики данных по умолчанию
    1. Дата и время
    2. Константа
    3. Справочник
    4. Простой

Установка

Установка с помощью Composer

Использование

Необходимо создать класс описывающий правила преобразования данных, отнаследовавшись от базавого класса BaseDataMapper.

Базово поддерживается 4 типа данных:

При необходимости можно расширить своими типами данных.

Создать свой DataMapper

Настройка своего DataMapper

Обращение к элементам вложенного массива осуществляется через точку "."

Например, правила ниже позволяют обратиться к значениям элемента "client" и "order"

Создание своего обработчика типа данных

Класс обработчика должен реализовывать интерфейс ResolveInterface

Использование DataMapper

Результат:

Array
(
    [Client] => Array
        (
            [Type] => Array
                (
                    [attributes] => Array
                        (
                            [id] => 1
                        )
                )
            [Id] => 1
            [Name] => Имя
            [FIO] => Фамилия Имя          
            [DateBirth] => 01.01.2000
            [Gender] => M
            [Order] => Array
                (
                    [Id] => 1
                )
        )
)

Если нужен XML

Результат:

Обработчики данных по умолчанию

Базово поддерживается 4 типа данных:

Если нужно указать массив соответствий с условием числовых диапазонов:

'type' => 'Directory', 'key' => '', 'field' => '',  params => [
    'conformityCondition' => [
        ['from' => 1, 'to' => 30, 'value' => 1],
        ['from' => 31, 'to' => 60, 'value' => 2],
        ['from' => 61, 'to' => 90, 'value' => 3],
        ['from' => 91, 'to' => 180, 'value' => 4],
        ['from' => 181, 'to' => 365, 'value' => 5],
        ['from' => 366, 'to' => 1095, 'value' => 6],
        ['from' => 1096, 'value' => 7],
        ['value' => 8],
    ]
]

Простой массив соответсвтий:

'type' => 'Directory', 'key' => '', 'field' => '', 'params' => [
    'conformity' => [
        'man' => 'M',
        'woman' => 'F',
    ],
    'default' => 'M',
],

Если нужно предварительно привести к числовому типу данных (int):

type='Directory', 'key' => '', 'field' => '', 'params' => ['type' => 'int']

Если нужно отсеять по доп. полям:

type='Directory', 'key' => '', 'field' => '', 'params' => [
    'propertyCode' => '',// код поля, содержащим массив доп. полей
    'propertyId' => '',// наименование нужного поля
    'propertyRowId' => '',// атрибут хранящий значение       
],

Можно указать, чтоб значение передавалось как часть параметра в ввиде аттрибута:

'type' => 'Directory', 'key' => '', 'field' => '', 'params' => ['attribute' => 'id']

Можно указать ключ "funcs", в котором перечислить функции, которыми необходимо обработать полученное значение:

'type' => 'Simple', 'key' => '', 'field' => '', 'funcs' => 'trim|mb_strtoupper'

Можно указать, чтоб значение передавалось как часть параметра в ввиде аттрибута:

type='Simple', key='' field='' params=['attribute' => 'id']

All versions of datamapper_tools with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
phpunit/phpunit Version *
nesbot/carbon Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dvasilenko/datamapper_tools contains the following files

Loading the files please wait ....