WP_CLI\Formatter::__construct PHP 메소드

__construct() 공개 메소드

public __construct ( array &$assoc_args, array $fields = null, string $prefix = false )
$assoc_args array Output format arguments.
$fields array Fields to display of each item.
$prefix string Check if fields have a standard prefix.
    public function __construct(&$assoc_args, $fields = null, $prefix = false)
    {
        $format_args = array('format' => 'table', 'fields' => $fields, 'field' => null);
        foreach (array('format', 'fields', 'field') as $key) {
            if (isset($assoc_args[$key])) {
                $format_args[$key] = $assoc_args[$key];
                unset($assoc_args[$key]);
            }
        }
        if (!is_array($format_args['fields'])) {
            $format_args['fields'] = explode(',', $format_args['fields']);
        }
        $format_args['fields'] = array_map('trim', $format_args['fields']);
        $this->args = $format_args;
        $this->prefix = $prefix;
    }