1
0
mirror of synced 2024-12-05 03:36:05 +03:00
bitrix-module/intaro.retailcrm/classes/general/AbstractBuilder.php

74 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* @category RetailCRM
* @package RetailCRM
* @author RetailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
/**
* Class AbstractBuilder
*
* @category RetailCRM
* @package RetailCRM
*/
abstract class AbstractBuilder
{
/**
* @param string $key
* @param mixed $default
* @return mixed|null
*/
public function getValue($key, $default = NULL)
{
return isset($this->dataCrm[$key]) && !empty($this->dataCrm[$key]) ? $this->dataCrm[$key] : $default;
}
/**
* @param array $array
* @param string $key
* @param mixed $default
* @return mixed|null
*/
public function getValueArray($array, $key, $default = NULL)
{
return isset($this->dataCrm[$array][$key]) && !empty($this->dataCrm[$array][$key]) ? $this->dataCrm[$array][$key] : $default;
}
/**
* @param array $array
* @param array $symbols
* @return array
*/
public function arrayClear(array $array, array $symbols = array('', 0, null))
{
return array_diff($array, $symbols);
}
/**
* @param $data
* @return array
*/
public function objectToArray($data)
{
return $this->arrayClear(json_decode(json_encode($data), true));
}
/**
*
* @param string|array|\SplFixedArray $str in utf-8
*
* @return array|bool|\SplFixedArray|string $str in SITE_CHARSET
* @global $APPLICATION
*/
public function fromJSON($str)
{
global $APPLICATION;
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
}
}