@param array $data

@return static|null
968652
public static function updateOrNull($data = null)
    {
        static $request;
        if (!$request) {
            $request = Di::getDefault()->getShared('request');
        }

        if (!$request->isPost() && !$request->isPut() && !$request->isPatch()) {
            return null;
        }

        $model = new static;

        $pkName = $model->getPrimaryKey();

        $_request = $request->get();

        $instance = static::get(isset($data[$pkName]) ? $data[$pkName] : $request->getId($pkName));

        if ($data === null || !isset($data[0])) {
            foreach ($model->getSafeFields() as $field) {
                if (isset($_request[$field])) {
                    $instance->$field = $_request[$field];
                }
            }
        }

        if ($data) {
            foreach ($data as $k => $v) {
                if (is_int($k)) {
                    $field = $v;
                    if (!isset($_request[$field])) {
                        throw new MissingFieldException($field);
                    }
                    $instance->$field = $_request[$field];
                } else {
                    $instance->$k = $v;
                }
            }
        }

        return $instance->update();
    }
1234460
public static function key(array $data) {
		$data += [
			'fields' => [],
			'locked' => [],
			'excluded' => []
		];
		return static::_compile(
			array_keys(Set::flatten($data['fields'])),
			$data['locked'],
			array_keys($data['excluded'])
		);
	}
257355
public function create(array &$data = null) {
		$modelClass = $this->getModelClass();

		$model = $modelClass::factory($data);
		$model->setDatagate($this);

		if ($this->hasLocator()) {
			$model->setLocator($this->getLocator());
		}

		if (empty($data)) {
			$model->forceInsert();
		}

		return $model;
	}
651358
public static function make($data = [])
    {
        // filter empty values
        $data = array_filter($data);

        // remove auto data;
        unset($data['id']);
        unset($data['created_at']);
        unset($data['updated_at']);

        //
        $model = new static($data);

        return $model;
    }
148639
public function initByData( array $data = null )
    {

        if( !$data ) {
            return null;
        }

        // table inheritance - ghetto?
        /*
        if( isset( $data['tableoid'] ) ) {
            if( $data['tableoid'] != static::OID ) {
                $repo = Repository::init( $data['tableoid'] );
                return $repo->initByData( $data );
            }
            unset( $data['tableoid'] );
        }
        */

        $key = call_user_func(
            array( $this->entityClass, 'keyGet' ),
            $data
        );

        // is this already in the cache? Are we initalising something we've already loaded?
        if( isset( $this->instancesPersisted[$key] ) ) {

            // Late loading? Don't need this anymore.
            $obj = $this->instancesPersisted[$key];
            $obj->__construct( $data );
            return $obj;

        }

        $obj = parent::initByData($data);
        $this->instancesPersisted[$key] = $obj;

        return $obj;

    }
456328
public function data($data = []) {
        if (count($data) == 0) {
            return $this->_data;
        }
        else {
            $this->_data = $data;
        }

        return null;
    }
465690
public function get($data) {
        $is_one = !static::isSomeArr($data);;
        if ($is_one) {
            $data = [$data];
        }
        $data = $this->getWithMulti($data);
        return $is_one ? reset($data) : $data;
    }
956281
public static function fromArray(array $data)
    {
        $config = isset($data['config']) ? $data['config'] : [];

        return new static($data['name'], $data['pluralName'], $data['uri'], $config);
    }
54655
protected function parseArrayOfPrimaryData(array $data)
    {
        $isValid = true;
        $result  = null;
        foreach ($data as $primaryData) {
            $parsed = $this->parseSinglePrimaryData($primaryData);
            if ($parsed === null) {
                $isValid = false;
            } else {
                $result[] = $parsed;
            }
        }

        return $isValid === true ? $result : null;
    }
783466
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('currency.add.before', $data, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        $data['modified'] = GC_TIME;
        $data['code'] = strtoupper($data['code']);

        if (!empty($data['default'])) {
            $data['status'] = 1;
            $this->config->set('currency', $data['code']);
        }

        $default = $this->getDefaultData();
        $data += $default;

        $currencies = $this->config->select('currencies', array());
        $currencies[$data['code']] = array_intersect_key($data, $default);

        $result = $this->config->set('currencies', $currencies);
        $this->hook->attach('currency.add.after', $data, $result, $this);
        return (bool) $result;
    }
1320744
final public static function deserialize(array $data)
    {
        return Reconstitution::reconstitute()->objectFrom(
            get_called_class(),
            RecursiveSerializer::deserialize($data, self::deserializationCallbacks())
        );
    }
921713
private function setData(array $data = null)
    {
        if (null === $data || count($data) === 0) {
            $data = new \stdClass();
        }

        $this->data = $data;

        return $this;
    }
572139
protected function create(array $data)
    {
        if (null === $this->resultFactory) {
            $this->resultFactory = new Factory();
        }

        return $this->resultFactory->create($data);
    }
180674
public function create(array $data)
    {
        if ($this->configHandler->hasParameter('is_cron_configured') &&
            $this->configHandler->getParameter('is_cron_configured')) {
            return $this->update($data, new ScheduledTask());
        }

        return null;
    }
406317
public static function nulls(array $data, $keys = null)
    {
        if ($keys === null) {
            $keys = array_keys($data);
        }

        if (!Arrays::isArray($keys)) {
            $keys = array($keys);
        }

        foreach ($keys as $key) {
            if (array_key_exists($key, $data) && empty($data[$key])) {
                $data[$key] = null;
            }
        }

        return $data;
    }
520893
public function setData(array $data)
    {
        foreach ($this->getData()->toArray() as $key => $value) {
            $this->getData()->offsetUnset($key);
        }

        $this->addData($data);

        return $this;
    }
1214620
public static function format(array $data) {
        return array_map(function ($item) {
            $args = static::toArrOrNone($item);
            if (false !== $args) {
                return $args;
            }
            return $item;
        }, $data);
    }