Prepare the arguments and return a Collection of arguments.

@since 0.1.0

@param string $cpt  Slug of the custom content.
@param array  $args Array of arguments to prepare.
@return Collection Collection of arguments.
974659
protected function prepareArguments( $cpt, array $args ) {
		$defaults = $this->getConfigKey( static::DEFAULTS );

		return ( new ArgumentCollection(
			array_replace_recursive( $defaults, $this->getConfigKey( $cpt ),
				$args )
		) )->prepareLabels();
	}
1053705
public function setArgsRequired($argData)
    {
        foreach ($argData as $argName => $required) {
            /* @var ArgumentScaffolder $arg */
            $arg = $this->args->find('argName', $argName);
            if (!$arg) {
                throw new InvalidArgumentException(sprintf(
                    'Tried to make arg %s required, but it was not added to %s',
                    $argName,
                    $this->operationName ?: '(unnamed operation)'
                ));
            }

            $arg->setRequired($required);
        }

        return $this;
    }
790295
public function prepareCommand($args)
    {
        $command = $this->getCommand();
        if (is_string($args)) {
            return $command . ' ' . trim($args);
        }

        foreach ($args as $arg) {
            if ($arg instanceof ModifierInterface) {
                $command = $arg->modify($command);
            } else {
                $command .= ' ' . escapeshellarg($arg);
            }
        }

        return $command;
    }
914746
public function prePersist(LifecycleEventArgs $args)
    {
        if ($args->getObject() instanceof BlockInterface && !$args->getObject() instanceof DocumentBlock) {
            $this->getService($args)->prePersist($args->getObject());
        }
    }
796905
public function arg(array $args, $char = "%")
  {
    $args = array_reverse($args, TRUE);

    foreach($args as $key => $val)
    {
      $args[$char . $key] = $val;
      unset($args[$key]);
    }

    $this->string = strtr($this->string, $args);

    return $this;
  }
492427
private function parse_args($args = [])
    {
        $args['NAMESPACE'] = '';

        $class_name = $this->sanitise_filename($args['CLASSNAME']);

        if ($this->is_nested_directory($class_name)) {
            $parts = \explode('\\', $class_name);
            $class = \array_pop($parts);

            $args['NAMESPACE'] = '\\' . \implode('\\', $parts);
            $args['CLASSNAME'] = $class;
        }

        return $args;
    }
826127
public function build($args)
    {
        $data = [];

        $args = Cuztom::merge($args, [
            'parent'   => $this,
            'metaType' => $this->metaType,
            'object'   => $this->object,
        ]);

        // Build with value
        if (Cuztom::isArray($this->value)) {
            $i = 0;

            foreach ($this->value as $value) {
                $args = Cuztom::merge($args, "index=>$i");

                $data[] = new BundleItem($args, $value);

                $i++;
            }
        }

        // Without value
        else {
            $args = Cuztom::merge($args, 'index=>0');

            $data[] = new BundleItem($args);
        }

        return $data;
    }
1095227
private function cmdReset($args)
    {
        $cmd = new ResetCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
509599
private function getParams(array $args)
    {
        if (count($args) == 0) {
            return [];
        }

        $params = array_slice($args, -1)[0];

        return is_array($params) ? $params : [];
    }
1316678
public function extractArgs($args)
	{
		foreach ($args as $k => $v) {
			if (property_exists($this, $k)) {
				$this->$k = $v;
			} else {
				throw new \InvalidArgumentException("{$k} is not a valid option.");
			}
		}
	}
598974
protected function _arrayToStringList(array $args, $namespace) {
        $out = array();
        foreach ($args as $key => $value) {
            $out[$namespace.'.member.'.($key+1)] = $value;
        }
        return $out;
    }
595908
public function addArgs(array $argData)
    {
        foreach ($argData as $argName => $type) {
            $this->removeArg($argName);
            $this->args->add(new ArgumentScaffolder($argName, $type));
        }

        return $this;
    }
27005
public function prePersist(LifecycleEventArgs $args)
    {
        $entity = $args->getObject();

        if ($entity instanceof ContentRoute) {
            $template = $this->templates[$entity->getTemplateName()];

            $entity->setTemplate($template['template']);
            $entity->setController($template['controller']);
        }
    }
955779
protected function set_pagination_args(array $args)
    {
        $args = wp_parse_args($args, array(
            'total_items' => 0,
            'total_pages' => 0,
            'per_page'    => 0
        ));

        if (!$args['total_pages'] && $args['per_page'] > 0) {
            $args['total_pages'] = ceil($args['total_items'] / $args['per_page']);
        }

        // Redirect if page number is invalid and headers are not already sent
        if (!headers_sent() && (!defined('DOING_AJAX') || !DOING_AJAX) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages']) {
            wp_redirect(add_query_arg('paged', $args['total_pages']));
            exit;
        }

        $this->pagination_args = $args;
    }
1297433
public static function emulateQuery(\PDO $PDO, array $args)
    {
        $argsCount = count($args);

        try {
            $stmt = $PDO->prepare($args[0]);

            if ($stmt === false) {
                throw new \Exception('prepare failed');
            }

            if ($argsCount == 4) {
                $stmt->setFetchMode($args[1], $args[2], $args[3]);
            }

            if ($argsCount == 3) {
                $stmt->setFetchMode($args[1], $args[2]);
            }

            if ($argsCount == 2) {
                $stmt->setFetchMode($args[1]);
            }

            $stmt->execute();
            return $stmt;
        } catch (\PDOException $exception) {
            throw new PDOException($exception);
        }
    }
1049464
private function processArguments(RawArgs $args, CommandCollection $namedCommands, array $argumentsToTest, array $optionsToTest)
    {
        $currentCommand = null;

        // Parse the arguments for command names until we fail to find a
        // matching command
        foreach ($argumentsToTest as $name) {
            if (!$namedCommands->contains($name)) {
                break;
            }

            $nextCommand = $namedCommands->get($name);

            if ($nextCommand->getConfig() instanceof OptionCommandConfig) {
                break;
            }

            $currentCommand = $nextCommand;
            $namedCommands = $currentCommand->getNamedSubCommands();
        }

        if (!$currentCommand) {
            return null;
        }

        return $this->processOptions($args, $currentCommand, $optionsToTest);
    }
1178398
public function prePersist(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();

        if (in_array('BespokeSupport\CreatedUpdatedDeletedBundle\Traits\EntityCreatedTrait', class_uses(get_class($entity)))) {
            /**
             * @var $entity \BespokeSupport\CreatedUpdatedDeletedBundle\Traits\EntityCreatedTrait
             */
            if (!$entity->getCreated()) {
                $entity->setCreated(new \DateTime());
            }
        }
    }