Create empty file

@param  array  command arguments
@return array
@author Dmitry (dio) Levashov
772418
protected function mkfile($args) {
		$target = $args['target'];
		$name   = $args['name'];
		
		if (($volume = $this->volume($target)) == false) {
			return array('error' => $this->error(self::ERROR_MKFILE, $name, self::ERROR_TRGDIR_NOT_FOUND, '#'.$target));
		}

		return ($file = $volume->mkfile($target, $args['name'])) == false
			? array('error' => $this->error(self::ERROR_MKFILE, $name, $volume->error()))
			: array('added' => array($file));
	}
1730
public static function createFromFilesGlobal(array $files) : array
    {
        $items = [];
        $files = self::normalizeSuperglobal($files);
        self::buildMap($files, $items);

        return $items;
    }
1268209
private function create_small_files() {
        $count = self::$paramsmallfilecount[$this->size];
        $this->log('createsmallfiles', $count, true);

        // Create resource with default textfile only.
        $resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
        $record = array('course' => $this->course,
                'name' => get_string('smallfiles', 'tool_generator'));
        $options = array('section' => 0);
        $resource = $resourcegenerator->create_instance($record, $options);

        // Add files.
        $fs = get_file_storage();
        $context = context_module::instance($resource->cmid);
        $filerecord = array('component' => 'mod_resource', 'filearea' => 'content',
                'contextid' => $context->id, 'itemid' => 0, 'filepath' => '/');
        for ($i = 0; $i < $count; $i++) {
            $filerecord['filename'] = 'smallfile' . $i . '.dat';

            // Generate random binary data (different for each file so it
            // doesn't compress unrealistically).
            $data = random_bytes_emulate($this->limit_filesize(self::$paramsmallfilesize[$this->size]));

            $fs->create_file_from_string($filerecord, $data);
            $this->dot($i, $count);
        }

        $this->end_log();
    }
1080580
public static function create(array $params = [])
    {
        $assembler = new static();
        if (!empty($params)) {
            array_walk($params, function($v, $k) use ($assembler) {
                $assembler->$k(function() use($v) {return $v;});
            });
            $assembler->assemble();
        }

        return $assembler;
    }
61603
public function createFile($fileName)
    {
        foreach ($this->languages() as $languageKey) {
            $file = $this->path."/{$languageKey}/{$fileName}.php";
            if (! $this->disk->exists($file)) {
                file_put_contents($file, "<?php \n\n return[];");
            }
        }
    }
680015
private function createCommandDocument()
    {
        $pipeline = [
            ['$match' => (object) $this->filter]
        ];

        if (isset($this->options['skip'])) {
            $pipeline[] = ['$skip' => $this->options['skip']];
        }

        if (isset($this->options['limit'])) {
            $pipeline[] = ['$limit' => $this->options['limit']];
        }

        $pipeline[] = ['$group' => ['_id' => null, 'n' => ['$sum' => 1]]];

        $cmd = [
            'aggregate' => $this->collectionName,
            'pipeline' => $pipeline,
            'cursor' => (object) [],
        ];

        if (isset($this->options['collation'])) {
            $cmd['collation'] = (object) $this->options['collation'];
        }

        if (isset($this->options['hint'])) {
            $cmd['hint'] = is_array($this->options['hint']) ? (object) $this->options['hint'] : $this->options['hint'];
        }

        if (isset($this->options['maxTimeMS'])) {
            $cmd['maxTimeMS'] = $this->options['maxTimeMS'];
        }

        return $cmd;
    }
1144273
public function form(array $args=null) {
        $input = $this->input;
        if($args) {
            $_input = [];
            foreach ($args as $arg) {
                $_input[$arg] = isset($input[$arg])?$input[$arg]:null;
            }
            $input = $_input;
        }
        return $input;
    }
836879
public static function createJson($strPath, $strFileName, array $data = [])
    {
        $cleanPath = self::cleanPath($strPath);

        if (!file_exists($strPath)) {
            mkdir($strPath, 0775);
        }

        $pathFile = $cleanPath . self::DS . $strFileName . '.json';

        if (!file_exists($pathFile)) {
            $file = fopen($pathFile, 'w+');
            fwrite($file, json_encode($data));

            return fclose($file);
        }

        return null;
    }
365672
public function run(array $args = null) {
		$exec = escapeshellcmd($this->command);
		if ($args) {
			$exec .= " ". implode(" ", array_map("escapeshellarg", (array) $args));
		}
		
		if ($this->sudo) {
			$this->suExec(sprintf($this->sudo." 2>&1", $exec), $this->verbose);
		} elseif ($this->verbose) {
			ob_start(function($s) {
				$this->output .= $s;
				return $s;
			}, 1);
			passthru($exec, $this->status);
			ob_end_flush();
		} elseif ($this->verbose !== false /* !quiet */) {
			ob_start([$this, "progress"], 1);
			passthru($exec . " 2>&1", $this->status);
			ob_end_flush();
		} else {
			exec($exec ." 2>&1", $output, $this->status);
			$this->output = implode("\n", $output);
		}
		
		if ($this->status) {
			throw new Exception("Command {$exec} failed ({$this->status})");
		}

		return $this;
	}
1193280
public static function allCustom()
    {
        // Response array
        $commands = [];

        // Loop through PHP files
        $dir = app_path('Console/Commands');
        if (!is_dir($dir)) return [];
        $files = scandir($dir);
        foreach ($files as $file) {
            if (!preg_match('#\w+\.php#', $file)) {
                continue;
            }

            // Build an instance of a command using the service container
            $path = $dir.'/'.$file;
            $class = 'App\Console\Commands\\'.basename($path, '.php');
            $command = app($class);

            // Validate command
            if (!is_a($command, 'Illuminate\Console\Command')) {
                continue;
            }

            // Get namespace
            $name = $command->getName();
            if (strpos($name, ':')) {
                list($namespace, $name) = explode(':', $name);
            } else {
                $namespace = 'misc';
            }

            // Massage name
            $name = str_replace('-', ' ', ucfirst($name));

            // Group commands by namespace
            $namespace = ucfirst($namespace);
            $name = ucfirst($name);
            if (!array_key_exists($namespace, $commands)) {
                $commands[$namespace] = [];
            }
            $commands[$namespace][$name] = $command;
        }

        // Return
        return $commands;
    }
731661
public static function argsToArray()
    {
        $_array = array();

        foreach ( func_get_args() as $_key => $_argument )
        {
            $_array[$_key] = $_argument;
        }

        //	Return the fresh array...
        return $_array;
    }
53847
private function createFile(array $fileInfo = []) {
    $file = new \Nuki\Models\Data\File($fileInfo['tmp_name'], $fileInfo['size']);
    
    $file->setExtension(pathinfo($fileInfo['name'], PATHINFO_EXTENSION));
    $file->setName(pathinfo($fileInfo['name'], PATHINFO_BASENAME));
    
    return $file;
  }
1066498
public function create(string $command, array $arguments = [], string $mode = self::MODE_DEFAULT): void
    {
        $this->storage[] = [
            'command' => $command,
            'arguments' => $arguments,
            'mode' => $mode,
        ];
    }
504509
public static function create()
	{
		switch (func_num_args()) {
			case 0:
				return new File();
			case 1:
				return new File(func_get_arg(0));
			case 2:
				return new File(func_get_arg(0), func_get_arg(1));
			case 3:
				return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2));
			case 4:
				return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
			case 5:
				return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
			case 6:
				return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
			case 7:
				return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
			case 8:
				return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
			default:
				throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
		}
	}
1072308
public function build(array $arguments = [])
    {
        $arguments = Arrays::arrayMergeRecursiveOverrule($this->arguments, $arguments);
        $arguments = $this->mergeArgumentsWithRequestArguments($arguments);

        $httpRequest = $this->request->getHttpRequest();

        $uriPathPrefix = $this->environment->isRewriteEnabled() ? '' : 'index.php/';
        $uriPathPrefix = $httpRequest->getScriptRequestPath() . $uriPathPrefix;
        $resolveContext = new ResolveContext($httpRequest->getBaseUri(), $arguments, $this->createAbsoluteUri, $uriPathPrefix);
        $resolvedUri = $this->router->resolve($resolveContext);
        if ($this->section !== '') {
            $resolvedUri = $resolvedUri->withFragment($this->section);
        }

        $this->lastArguments = $arguments;
        return (string)$resolvedUri;
    }
722623
public static function build($command, array $args = []): string
    {
        $stringArgs = [];
        $realCommand = $command;

        if (count($args) > 0) {
            foreach ($args as $key => $value) {
                $value = trim($value);
                $key = trim($key);

                if (strpos($key, '-') !== 0) {
                    $key = strlen($key) === 1 ? '-' . $key : '--' . $key;
                }

                if (strlen($value) > 0) {
                    $stringArgs[] = $key . '="' . addcslashes($value, '"') . '"';
                } else {
                    $stringArgs[] = $key;
                }
            }
        }

        if (count($stringArgs)) {
            $realCommand = $command . ' ' . implode(' ', $stringArgs);
        }

        return $realCommand;
    }
948043
public static function make(array $data = array())
    {
        if (static::isFileOrFolder($data)) {
            $tag = $data['.tag'];

            //File
            if (static::isFile($tag)) {
                return new FileMetadata($data);
            }

            //Folder
            if (static::isFolder($tag)) {
                return new FolderMetadata($data);
            }
        }

        //Temporary Link
        if (static::isTemporaryLink($data)) {
            return new TemporaryLink($data);
        }

        //List
        if (static::isList($data)) {
            return new MetadataCollection($data);
        }

        //Search Results
        if (static::isSearchResult($data)) {
            return new SearchResults($data);
        }

        //Deleted File/Folder
        if (static::isDeletedFileOrFolder($data)) {
            return new DeletedMetadata($data);
        }

        //Base Model
        return new BaseModel($data);
    }