@param string $data

@throws UnexpectedValueException

@return array|null
502261
private function extractScriptTagBody(&$data)
    {
        $result = null;
        $name = $this->extractScriptDataValue($data);
        if (is_string($name)) {
            $value = $this->extractScriptDataValue($data);
            if (is_array($value)) {
                $result = [$name, $value];
            }
        }

        return $result;
    }
364357
protected function getItemsData($object, string $format = null, array $context = []): array
    {
        $data = [];

        foreach ($object as $obj) {
            $item = $this->normalizer->normalize($obj, $format, $context);
            if (!\is_array($item)) {
                throw new UnexpectedValueException('Expected item to be an array');
            }
            $data['_embedded']['item'][] = $item;
            $data['_links']['item'][] = $item['_links']['self'];
        }

        return $data;
    }
697293
public function unserialize($serialized)
    {
        $data = unserialize($serialized);
        if (!is_array($data)) {
            throw new \UnexpectedValueException('Unserialized data is not an array');
        }

        // TODO: check existence
        $this->message      = CustomAmqpMessage::fromProperties($data['message']);
        $this->tag          = (string) $data['tag'];
        $this->exchange     = (string) $data['exchange'];
        $this->queue        = (string) $data['queue'];
        $this->routingKey   = (string) $data['routingKey'];
        $this->redelivered  = (bool) $data['routingKey'];
    }
535982
public static function fromArray(array $data)
    {
        $result = '';
        foreach ($data as $name => $value) {
            $value = StringHelper::toString($value, "'", Serialize::SERIALIZE_JSON);
            $result .= "$name=$value; ";
        }

        return $result === '' ? null : rtrim($result);
    }
533729
public function getAdapter()
    {
        if(!$this->_adapter instanceof KDatabaseAdapterInterface)
        {
            $this->_adapter = $this->getObject($this->_adapter);

            if(!$this->_adapter instanceof KDatabaseAdapterInterface)
            {
                throw new UnexpectedValueException(
                    'Adapter: '.get_class($this->_adapter).' does not implement KDatabaseAdapterInterface'
                );
            }
        }

        return $this->_adapter;
    }
1266749
public function parseReadData($data)
	{
		$results = array();

		foreach ($data as $row) {
			if (is_array($row)) {
				$key = $row['key'];
				$value = $row['value'];
			} elseif (is_object($row)) {
				$key = $row->key;
				$value = $row->value;
			} else {
				$msg = 'Expected array or object, got '.gettype($row);
				throw new \UnexpectedValueException($msg);
			}

			SettingsUtilities::set($results, $key, $value);
		}

		return $results;
	}
260314
public function unserialize($data) {
        $value = $this->fromData($data);
        foreach ($this->getFilters() as $filter) {
            $value = $filter->toValue($value);
        }
        return $value;
    }
1039868
static function decodeElementRawData(string $data): ?array
    {
        $data = json_decode($data, true);
        if (is_array($data) &&
                isset($data['id']) && is_string($data['id']) && strlen($data['id']) > 0 &&
                isset($data['type']) && is_string($data['type']) && strlen($data['type']) > 0 &&
                isset($data['data']) && is_array($data['data'])
        ) {
            return $data;
        }
        return null;
    }
344728
protected function retrieveData($data)
    {
        $filter = $this->getInputFilter();

        if (null !== $filter) {
            return $filter->getValues();
        }

        return (array)$data;
    }
1353782
private function parseUI16($data)
    {
        if (!isset($data[1])) {
            throw new UnexpectedValueException();
        }
        $unpacked = unpack('n', $data);

        return array_shift($unpacked);
    }
241272
public static function valueTrim(array $data)
    {
        if (is_scalar($data)) {
            return trim($data);
        }

        array_walk_recursive($data, function (&$value) {
            $value = trim($value);
        });

        return $data;
    }
1188084
protected function checkConfig(array $config)
    {
        if (!isset($config['dataSource']) || !is_array($config['dataSource'])) {
            throw new UnexpectedValueException($this->translate(
                'Information about data source in metadata configuration should be an array or Traversable.'
            ));
        }
        if (!isset($config['types']) || !is_array($config['types'])) {
            throw new UnexpectedValueException($this->translate(
                'Information about types in metadata configuration should be an array or Traversable.'
            ));
        }
        if (!isset($config['fields']) || !is_array($config['fields'])) {
            throw new UnexpectedValueException($this->translate(
                'Information about fields in metadata configuration should be an array or Traversable.'
            ));
        }
    }
1044390
private function extractScriptDataValue(&$data)
    {
        $result = null;
        if (isset($data[0])) {
            $type = $this->parseUI8($data[0]);
            $data = substr($data, 1);
            switch ($type) {
                case 0: // Number
                    $result = $this->extractScriptDataValue_Double($data);
                    break;
                case 1: // Boolean
                    $result = $this->extractScriptDataValue_Boolean($data);
                    break;
                case 2: // String
                    $result = $this->extractScriptDataValue_String($data);
                    break;
                case 7: // Reference
                    $result = $this->extractScriptDataValue_UI16($data);
                    break;
                case 8: // ECMA array
                    $result = $this->extractScriptDataValue_ECMAArray($data);
                case 9: // Object end marker
                    $result = null;
                    break;
                //case 3: // Object
                //case 4: // MovieClip (reserved, not supported)
                //case 5: // Null
                //case 6: // Undefined
                //case 10: // Strict array
                //case 11: // Date
                //case 12: // Long string
                default:
                    throw new UnexpectedValueException();
            }
        }

        return $result;
    }
50911
public function offsetGet($offset)
    {
        switch ($offset) {
            case 'operator':
                return $this->getOperator();
                break;

            case 'leftSubTerm':
                return $this->getLeftSubTerm();
                break;

            case 'rightSubTerm':
                return $this->getRightSubTerm();
                break;

            default:
                throw new \UnexpectedValueException("Offset $offset does not exist.");
        }
    }
17597
public function convertFieldValueFromForm($data)
    {
        if ($data === null) {
            return null;
        }

        $imageData = array(
            'inputUri' => $data->getRealPath(),
            'fileName' => $data->getClientOriginalName(),
            'fileSize' => $data->getSize(),
        );

        return new ImageValue($imageData);
    }
538683
private function getErrorFromRegData($data)
	{
		$data['username'] = e($data['username']);
		$validator = Validator::make($data, Validators::rulesForRegisterAcc(), Validators::messagesForErrors());
		$userMessages = $validator->messages();

		if ($validator->fails()) {
			$result['errors'] = array(
				'username'        => $userMessages->first('username'),
				'callback'        => $userMessages->first('callback'),
				'email'           => $userMessages->first('email'),
				'password'        => $userMessages->first('password'),
				'confirmPassword' => $userMessages->first('confirmPassword'),
			);

			return $result;
		}

		return null;
	}
166133
public function getDatatypes() {
        if (empty($this->data)) {
            $this->data = $this->parse_string();
        }
        if (!is_array($this->data)) {
            throw new \UnexpectedValueException('No data set yet.');
        }

        $result = [];
        foreach ($this->titles as $cName) {
            $column = array_column($this->data, $cName);
            $cDatatypes = array_map(DatatypeEnum::class . '::getValidTypeFromSample', $column);

            $result[$cName] = $this->getMostFrequentDatatypeForColumn($cDatatypes);
        }

        $this->data_types = $result;

        return !empty($this->data_types) ? $this->data_types : [];
    }