Check data of constructor input

@param array $data
@throws \common_Exception
183030
protected function checkData(array $data)
    {
        if (! isset($data[self::STATUS]) || ! in_array($data[self::STATUS], self::$availableStatus)) {
            throw new \common_Exception(
                __('A maintenance status must have a STATUS: "%s" or "%s"', self::LIVE_MODE, self::OFFLINE_MODE)
            );
        }
    }
1326518
protected function isValidConditionData($data)
    {
        if (!array_key_exists('field', $data)) {
            throw new MissingConditionAttributeException('field');
        }
        if (!array_key_exists('operator', $data)) {
            throw new MissingConditionAttributeException('operator');
        }
        if (!array_key_exists('type', $data)) {
            throw new MissingConditionAttributeException('type');
        }
        if (!array_key_exists('value', $data)) {
            throw new MissingConditionAttributeException('value');
        }

        return true;
    }
736816
protected function returnValidXml($data)
    {
        if (empty($data)) {
            throw new common_exception_NotFound('Delivery execution not found.');
        }

        $doc = @simplexml_load_string($data);
        if (!$doc) {
            common_Logger::i('invalid xml result');
            throw new Exception('Xml output is malformed.');
        }

        // force XML content type header
        header('Content-Type: application/xml');

        echo $data;
        exit(0);
    }
941082
protected function extractSingleItemData(array $data) {
        if ($this->singleResponseKey && !array_key_exists($this->singleResponseKey, $data)) {
            throw new Exception('Invalid response, missing field ' . $this->singleResponseKey);
        }

        return ($this->singleResponseKey) ? $data[$this->singleResponseKey] : $data;
    }
983570
public function failed(array $data)
    {
        $handler = $this->container->make($data['class']);

        if (method_exists($handler, 'failed')) {
            call_user_func_array(array($handler, 'failed'), unserialize($data['data']));
        }
    }
26481
protected function onInput($data)
    {
        //Process data here
        foreach ($this->params as $func => $columns) {
            switch ($func) {
            case "upper":
                foreach ($columns as $col) {
                    $data[$col] = strtoupper($data[$col]);
                }
                break;
            case "lower":
                foreach ($columns as $col) {
                    $data[$col] = strtolower($data[$col]);
                }
                break;
            case "first-cap":
                foreach ($columns as $col) {
                    $data[$col] = ucfirst($data[$col]);
                }
                break;
            case "all-cap":
                foreach ($columns as $col) {
                    $data[$col] = ucwords($data[$col]);
                }
                break;
            }
        }
        $this->next($data);
    }
992886
protected final function validateUpdateData(array $data = null) {
		if ($data === null && isset($this->_formData)) {
			$data = $this->_formData;
		}
		if ($this->rules) {
			$newRules = [];
			foreach ($data as $key => $v) {
				if (isset($this->rules[ $key ])) {
					$newRules[ $key ] = $this->rules[ $key ];
				}
			}
			if ($newRules) {
				return $this->validateData($newRules, $data);
			}
		}

		return true;
	}
561681
public function validate(array $data) : bool
    {
        $passed = true;
        $this->invalidFields = [];
        $rules = $this->getRules();
        foreach ($rules as $validation => $fields) {
            foreach ($fields as $key => $value) {
                $field = $this->getFieldInfo($key, $value);
                $validationInstance = $this->getValidation($validation);
                $validationStatus = $validationInstance->run($field, $data);
                $passed = $passed && $validationStatus;
                $this->invalidFields = array_merge_recursive(
                        $this->invalidFields, $validationInstance->getMessages()
                );
            }
        }
        return $passed;
    }
1319296
public function onData(string $data)
    {
        $data = trim($data);
        $this->log('->' . $data);
        $chunks = explode(' ', $data);
        $command = $chunks[0];
        unset($chunks[0]);
        $input = '';
        if (count($chunks) > 0) {
            $input = implode(' ', $chunks);
        }
        $input = trim($input);
        if ($this->node->getCommands()->has($command)) {
            $this
                ->node
                ->getCommands()
                ->get($command)
                ->handle($this, $input)
                ->then(function (array $lines) {
                    foreach ($lines as $line) {
                        $this->write($line);
                    }
                });
            return;
        }

        $list = implode(', ', $this->node->getCommands()->keys());
        $this->write(
            '# Unknown command. Try ' . substr_replace($list, ' or ', strrpos($list, ', '), 2)
        );
    }
944418
private function setDataset(array $data = [])
    {
        // If we don't have any data, use input if we're allowed
        if ( ! count($data) && $this->allowHydrationFromInput) $data = Input::all();

        $this->dataset = $data;
    }
684446
public function data($data)
    {
        if ($this->_rcpt == false) {
            throw new SMTPException(__('Must call RCPT before calling DATA'));
        }

        $this->_send('DATA');
        $this->_expect(354, 120);

        foreach ($this->_header_fields as $name => $body) {
            // Every header can contain an array. Will insert multiple header fields of that type with the contents of array.
            // Useful for multiple recipients, for instance.
            if (!is_array($body)) {
                $body = array($body);
            }

            foreach ($body as $val) {
                $this->_send($name . ': ' . $val);
            }
        }
        // Send an empty newline. Solves bugs with Apple Mail
        $this->_send('');

        // Because the message can contain \n as a newline, replace all \r\n with \n and explode on \n.
        // The send() function will use the proper line ending (\r\n).
        $data = str_replace("\r\n", "\n", $data);
        $data_arr = explode("\n", $data);

        foreach ($data_arr as $line) {
            // Escape line if first character is a period (dot). http://tools.ietf.org/html/rfc2821#section-4.5.2
            if (strpos($line, '.') === 0) {
                $line = '.' . $line;
            }
            $this->_send($line);
        }

        $this->_send('.');
        $this->_expect(250, 600);
        $this->_data = true;
    }
468428
protected function HLUpdate(array $data)
    {
        $return = [];
        if (empty($data['NAME'])) {
            throw new Exception('You must set NAME');
        }
        if ($id = $this->HLGetIdByCode($data['NAME'])) {
            $arLoad = $data;
            unset($arLoad['LANGS'], $arLoad['RIGHTS'], $arLoad['NAME']);
            if ($arLoad) {
                $result = HighloadBlockTable::update($id, $arLoad);
                if ($result->isSuccess()) {
                    if (!empty($data['LANGS'])) {
                        $this->HLSetLangs($id, $data['LANGS']);
                    }
                    if (!empty($data['RIGHTS'])) {
                        $this->HLSetRights($id, $data['RIGHTS']);
                    }
                    $return[] = "Update {$data['NAME']} ({$id}) highload block";
                } else {
                    throw new Exception("Can't update {$data['NAME']} ({$id}) highload block: " . implode(', ', $result->getErrorMessages()));
                }
            } elseif (!empty($data['RIGHTS'])) {
                $this->HLSetRights($id, $data['RIGHTS']);
            } elseif (!empty($data['LANGS'])) {
                $this->HLSetLangs($id, $data['LANGS']);
            }
        } else {
            throw new Exception("Hl entity with name {$data['NAME']} does not exist");
        }

        return $return;
    }
750598
protected function checkItems(array $data)
	{
		foreach ($data as &$item)
		{
			if( ! $item instanceof Model )
			{
				$item = new $this->defaultModel($item);
			}
		}

		return $data;
	}
528932
private function setData($data) {

		if(false === is_array($data)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
   		}

		$this -> data = $data;
	}
995552
protected function validate(stdClass $data): void
    {
        $config = $this->getConfig();
        $schema = $this->readSchema();

        // No need to validate empty data (empty() does not work on objects)
        $dataArray = Convert::objectToArray($data);
        if (empty($dataArray)) {
            if ($config['allowEmptyData'] === false) {
                throw new JsonValidationException('Empty data is not allowed.');
            }
            $this->warnings[] = "Skipping validation of empty data";

            return;
        }

        // No need to validate with empty schema (empty() does not work on objects)
        $schemaArray = Convert::objectToArray($schema);
        if (empty($schemaArray)) {
            if ($config['allowEmptySchema'] === false) {
                throw new JsonValidationException('Empty schema is not allowed.');
            }
            $this->warnings[] = "Skipping validation with empty schema";

            return;
        }

        $this->runValidator($data, $schema);
    }
1189005
public function init($data = null)
    {
        $this->meta = array();

        $data = explode('*', (string)$data);

        // ...skip unilateral untagged server responses
        for ($i=0, $len=count($data); $i<$len; $i++) {
            $data_item = &$data[$i];
            if (preg_match('/^ SORT/i', $data_item)) {
                // valid response, initialize raw_data for is_error()
                $this->raw_data = '';
                $data_item = substr($data_item, 5);
                break;
            }
            else if (preg_match('/^ (E?SEARCH)/i', $data_item, $m)) {
                // valid response, initialize raw_data for is_error()
                $this->raw_data = '';
                $data_item = substr($data_item, strlen($m[0]));

                if (strtoupper($m[1]) == 'ESEARCH') {
                    $data_item = trim($data_item);
                    // remove MODSEQ response
                    if (preg_match('/\(MODSEQ ([0-9]+)\)$/i', $data_item, $m)) {
                        $data_item = substr($data_item, 0, -strlen($m[0]));
                        $this->params['MODSEQ'] = $m[1];
                    }
                    // remove TAG response part
                    if (preg_match('/^\(TAG ["a-z0-9]+\)\s*/i', $data_item, $m)) {
                        $data_item = substr($data_item, strlen($m[0]));
                    }
                    // remove UID
                    $data_item = preg_replace('/^UID\s*/i', '', $data_item);

                    // ESEARCH parameters
                    while (preg_match('/^([a-z]+) ([0-9:,]+)\s*/i', $data_item, $m)) {
                        $param = strtoupper($m[1]);
                        $value = $m[2];

                        $this->params[$param] = $value;
                        $data_item = substr($data_item, strlen($m[0]));

                        if (in_array($param, array('COUNT', 'MIN', 'MAX'))) {
                            $this->meta[strtolower($param)] = (int) $value;
                        }
                    }

// @TODO: Implement compression using compressMessageSet() in __sleep() and __wakeup() ?
// @TODO: work with compressed result?!
                    if (isset($this->params['ALL'])) {
                        $data_item = implode(self::SEPARATOR_ELEMENT,
                            rcube_imap_generic::uncompressMessageSet($this->params['ALL']));
                    }
                }

                break;
            }

            unset($data[$i]);
        }

        $data = array_filter($data);

        if (empty($data)) {
            return;
        }

        $data = array_shift($data);
        $data = trim($data);
        $data = preg_replace('/[\r\n]/', '', $data);
        $data = preg_replace('/\s+/', ' ', $data);

        $this->raw_data = $data;
    }
93742
private static function _parseData(array $data)
    {
        foreach($data as $key => $value) {
            self::$_data[\mb_strtolower($key)] = $value;
        }
    }