Builds asset data
@param array $data
@return array
438008
public function build(array $data)
    {
        if (is_array($data['asset'])) {
            $type = 'js';
        } else if (strpos($data['asset'], 'http') === 0) {
            $type = 'external';
        } else {
            $type = pathinfo($data['asset'], PATHINFO_EXTENSION);
        }

        $data += array(
            'file' => '',
            'key' => null,
            'merge' => '',
            'version' => '',
            'type' => $type,
            'text' => false,
            'condition' => '',
            'position' => 'top'
        );

        if (!isset($data['weight'])) {
            $data['weight'] = $this->getNextWeight($data['type'], $data['position']);
        }

        if (!in_array($data['type'], array('css', 'js'))) {
            $data['text'] = true;
        }

        if (($type !== 'external' && $type != $data['type']) || is_array($data['asset'])) {
            $data['text'] = true; // Arrays will be converted to JSON
        }

        if ($data['text']) {

            if (!isset($data['key'])) {
                $data['key'] = 'text.' . md5(json_encode($data['asset']));
            }

            return $data;
        }

        if (gplcart_path_is_absolute($data['asset'])) {
            $data['file'] = $data['asset'];
            $data['asset'] = gplcart_path_relative($data['asset']);
        } else if ($type !== 'external') {
            $data['file'] = gplcart_path_absolute($data['asset']);
        }

        if (!empty($data['file'])) {

            if (!file_exists($data['file'])) {
                return array();
            }

            $data['version'] = filemtime($data['file']);
        }

        $data['key'] = $data['asset'] = str_replace('\\', '/', $data['asset']);
        return $data;
    }
1367440
protected function buildModel(array $data = array()){
        $Model = NULL;
        if (isset($this->model)){
            $Model = new $this->model();
            $Model->setBaseUrl($this->getBaseUrl());
            if ($this->getAuth() !== NULL) {
                $Model->setAuth($this->getAuth());
            }
            if (!empty($data)){
                foreach($data as $key => $value){
                    $Model->set($key,$value);
                }
            }
        }
        return $Model;
    }
1330376
public function create(array $data)
    {
        $user = User::create([
            'name'                  => $data['name'],
            'email'                 => $data['email'],
            'password'              => bcrypt($data['password']),
            'birthday_at'           => $data['birthday_at'],
            'locale'                => $data['locale'],
            'gender'                => $data['gender'],
            'city'                  => $data['city'],
            'about'                 => $data['about'],
            'profession'            => $data['profession'],
            'hobbies'               => $data['hobbies'],
            'homepage'              => $data['homepage'],
            'skype'                 => $data['skype'],
            'facebook'              => $data['facebook'],
            'twitter'               => $data['twitter'],
            'main_character'        => $data['main_character'],
            'main_guild'            => $data['main_guild'],
            'favorite_race'         => $data['favorite_race'],
            'favorite_spec'         => $data['favorite_spec'],
            'favorite_instance'     => $data['favorite_instance'],
            'favorite_battleground' => $data['favorite_battleground'],
        ]);

        return $user;
    }
794333
protected function prepareData($data)
    {
        if(!is_array($data))
        {
            $data = [];
        }
        
        $data['access_token'] = $this->config->accessToken;
        
        return http_build_query($data);
    }
515932
public function buildPostData($data)
    {
        $binary_data = false;
        if (is_array($data)) {
            // Return JSON-encoded string when the request's content-type is JSON.
            if (isset($this->headers['Content-Type']) &&
                preg_match($this->jsonPattern, $this->headers['Content-Type'])) {
                $json_str = json_encode($data);
                if (!($json_str === false)) {
                    $data = $json_str;
                }
            } else {
                // Manually build a single-dimensional array from a multi-dimensional array as using curl_setopt($ch,
                // CURLOPT_POSTFIELDS, $data) doesn't correctly handle multi-dimensional arrays when files are
                // referenced.
                if (self::is_array_multidim($data)) {
                    $data = self::array_flatten_multidim($data);
                }

                // Modify array values to ensure any referenced files are properly handled depending on the support of
                // the @filename API or CURLFile usage. This also fixes the warning "curl_setopt(): The usage of the
                // @filename API for file uploading is deprecated. Please use the CURLFile class instead". Ignore
                // non-file values prefixed with the @ character.
                foreach ($data as $key => $value) {
                    if (is_string($value) && strpos($value, '@') === 0 && is_file(substr($value, 1))) {
                        $binary_data = true;
                        if (class_exists('CURLFile')) {
                            $data[$key] = new \CURLFile(substr($value, 1));
                        }
                    } elseif ($value instanceof \CURLFile) {
                        $binary_data = true;
                    }
                }
            }
        }

        if (!$binary_data && (is_array($data) || is_object($data))) {
            $data = http_build_query($data, '', '&');
        }

        return $data;
    }
324610
public function build(array $data = [])
    {
        if(!$this->oAuth2Credential)
            $this->oAuth();

        $data = $this->mergeData($data);

        $adwordsSession = new AdWordsSessionBuilder();

        return $adwordsSession->withDeveloperToken($data['developerToken'])
                ->withClientCustomerId($data['clientCustomerId'])
                ->withOAuth2Credential($this->oAuth2Credential)
                ->build();
    }
113026
public function process(array $data)
    {
        $processedData = [
            'meta' => Hash::get($data, 'meta'),
            'data' => []
        ];
        $processedData['meta']['type'] = 'Module';
        $processedData['meta']['title'] = $this->name();
        unset($data['meta']);
        foreach ($data as $attr => $value) {
            $processedData['data'][$attr] = $value;
        }
        return $processedData;
    }
741092
public function createModel(Array $data)
    {
        $volumes = Craft::$app->getVolumes();
        
        $volume = $volumes->createVolume([
            'id' => array_key_exists('id', $data) ? $data['id'] : null,
            'type' => $data['type'],
            'name' => $data['name'],
            'handle' => $data['handle'],
            'hasUrls' => array_key_exists('hasUrls', $data) ? $data['hasUrls'] : false,
            'url' => array_key_exists('hasUrls', $data) ? $data['url'] : '',
            'sortOrder' => $data['sortOrder'],
            'settings' => $data['typesettings']
        ]);

        if (array_key_exists('fieldLayout', $data)) {
            $requiredFields = array();
            if (array_key_exists('requiredFields', $data)) {
                foreach ($data['requiredFields'] as $handle) {
                    $field = Craft::$app->fields->getFieldByHandle($handle);
                    if ($field) {
                        $requiredFields[] = $field->id;
                    }
                }
            }

            $layout = array();
            foreach ($data['fieldLayout'] as $key => $fields) {
                $fieldIds = array();
                foreach ($fields as $field) {
                    $existingField = Craft::$app->fields->getFieldByHandle($field);
                    if ($existingField) {
                        $fieldIds[] = $existingField->id;
                    } else {
                        $this->addError('error', 'Missing field: '.$field.' can not add to field layout for Asset Volume: '.$volume->handle);
                    }
                }
                $layout[$key] = $fieldIds;
            }

            $fieldLayout = Craft::$app->fields->assembleLayout($layout, $requiredFields);
            $fieldLayout->type = Asset::class;
            $volume->fieldLayout = $fieldLayout;
        }
        return $volume;
    }
552841
protected function buildSendPackageData(array $data)
    {
        if (preg_match('/^(62[1-9]{1}[0-9]{1,2})[0-9]{6,8}$/', $data[ 'msisdn' ]) == 1) {
            $data[ 'msisdn' ] = '0' . substr($data[ 'msisdn' ], 2);
        } elseif (preg_match('/^(\+62[1-9]{1}[0-9]{1,2})[0-9]{6,8}$/', $data[ 'msisdn' ]) == 1) {
            $data[ 'msisdn' ] = '0' . substr($data[ 'msisdn' ], 3);
        }

        if (preg_match('/^(0[1-9]{1}[0-9]{1,2})[0-9]{6,8}$/', $data[ 'msisdn' ]) == 1) {
            return [
                'number'          => trim($data[ 'msisdn' ]),
                'message'         => urlencode(stripslashes(utf8_encode($data[ 'message' ]))),
                'sendingdatetime' => isset($data[ 'sendingTime' ]) ? $data[ 'sendingTime' ] : null,
            ];
        }

        return false;
    }
392880
private function initFixtures($data)
    {
        $fixtures = [];
        $parser = $this->container->get('kunstmaan_fixtures.parser.parser');

        foreach ($data as $file) {
            foreach ($file as $class => $specs) {
                foreach ($specs as $name => $options) {
                    $fixture = new Fixture($name, $class, $options);
                    $fixtures = $parser->parseSpec($name, $fixture, $fixtures);
                }
            }
        }

        return $fixtures;
    }
1214620
public static function format(array $data) {
        return array_map(function ($item) {
            $args = static::toArrOrNone($item);
            if (false !== $args) {
                return $args;
            }
            return $item;
        }, $data);
    }
982240
protected function asArray($data = []): array
    {
        if ($data instanceof Collection) {
            $data = $data->all();
        } elseif ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        return $data;
    }
1180202
public function create(array $data = [])
    {
        $lists = new Lists();

        if (array_key_exists('items', $data)) {
            $lists->setItems(
                $this->getListItemFactory()->createCollection($data['items'])
            );
        }

        /** Images */
        if (array_key_exists('poster_path', $data)) {
            $lists->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
        }

        return $this->hydrate($lists, $data);
    }
211085
public function populateData(array $data)
    {
        //attempt to make the storage path if it doesn't already exist
        $path = $this->getStoragePath();

        if (!is_dir($path)) {
            mkdir($path);
        }

        //try to fetch the JSON file
        $file = $path.$this->getOption('name').'.json';

        if (file_exists($file)) {
            $json     = file_get_contents($file);
            $saveData = json_decode($json);

            //run through the saveData and update the associated fields that we populated from the edit fields
            foreach ($saveData as $field => $value) {
                if (array_key_exists($field, $data)) {
                    $data[$field] = $value;
                }
            }
        }

        return $data;
    }
1073315
public function create(array $data = [])
    {
        $listItem = new ListItem();

        /** Images */
        if (array_key_exists('backdrop_path', $data)) {
            $listItem->setBackdropImage(
                $this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path')
            );
        }

        if (array_key_exists('poster_path', $data)) {
            $listItem->setPosterImage(
                $this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')
            );
        }

        return $this->hydrate($listItem, $data);
    }
1297697
protected function buildRows(array $data)
    {
        $this->rows = collect($data)->map(function ($model, $number) {
            return new Row($number, $model);
        });

        if ($this->rowsCallback) {
            $this->rows->map($this->rowsCallback);
        }
    }
908296
public function create(array $data)
    {
        $parameters = ['name' => $data['name']];

        foreach ($data['config'] as $key => $value) {
            $parameters["config.$key"] = $value;
        }

        return $this->post('plugins/', [
            'json' => $parameters
        ]);
    }