描述控制台
@param Console $console
@param array $options
@return string|mixed
186131
protected function describeConsole(Driver $console, array $options = []) {
        $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
        $description = new ConsoleDescription($console, $describedNamespace);

        if (isset($options['raw_text']) && $options['raw_text']) {
            $width = $this->getColumnWidth($description->getCommands());

            foreach ($description->getCommands() as $command) {
                $this->writeText(sprintf("%-${width}s %s", $command->getName(), $command->getDescription()), $options);
                $this->writeText("\n");
            }
        }
        else {
            if ('' != $help = $console->help) {
                $this->writeText("$help\n\n", $options);
            }

            $this->writeText("<comment>Usage:</comment>\n", $options);
            $this->writeText("  command [options] [arguments]\n\n", $options);

            $this->describeInputDefinition(new InputDefinition($console->definition->getOptions()), $options);

            $this->writeText("\n");
            $this->writeText("\n");

            $width = $this->getColumnWidth($description->getCommands());

            if ($describedNamespace) {
                $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
            }
            else {
                $this->writeText('<comment>Available commands:</comment>', $options);
            }

            // add commands by namespace
            foreach ($description->getNamespaces() as $namespace) {
                if (!$describedNamespace && ConsoleDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                    $this->writeText("\n");
                    $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
                }

                foreach ($namespace['commands'] as $name) {
                    $this->writeText("\n");
                    $spacingWidth = $width - strlen($name);
                    $this->writeText(sprintf("  <info>%s</info>%s%s", $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)
                        ->getDescription()), $options);
                }
            }

            $this->writeText("\n");
        }
    }
148894
public static function createModel($options) {

        if ( !isset($options['model']) ) return tprintError("Error : --model is needed.");
        if ( !isset($options['table']) ) return tprintError("Error : --table is needed.");
        if ( !isset($options['module']) ) return tprintError("Error : --module is needed.");
        if ( !isset($options['pk']) ) $options['pk'] = 'id';
        if ( !isset($options['author']) ) $options['author'] = 'yangjian';
        if ( !isset($options['email']) ) $options['email'] = 'yangjian102621@gmail.com';
        if ( !isset($options['date']) ) $options['date'] = date('Y-m-d');

        $tempContent = file_get_contents(dirname(__DIR__)."/template/model.tpl");
        $modelFile = $options['module_dir'].ucfirst(GModel::underline2hump($options['model']))."Dao.php";
        if ( file_exists($modelFile) ) { //若文件已经存在则跳过
            return tprintWarning("Warnning : model file '{$modelFile}' has existed，skiped.");
        }

        $replacement = array(
            "{table_name}" => $options['table'],
            "{desc}" => $options['desc'] ? $options['desc'] : "{$options['table']} 数据表模型",
            "{pk}" => $options['pk'],
            "{model_name}" => ucfirst(GModel::underline2hump($options['model']))."Dao",
            "{author}" => $options['author'],
            "{email}" => $options['email'],
            "{autoPrimaryKey}" => '',
            "{module}" => $options['module'],
            "{flagments}" => '',
            "{sharding_num}" => '',
        );
        $content = str_replace(array_keys($replacement), $replacement, $tempContent);
        if ( file_put_contents($modelFile, $content) !== false ) {
            tprintOk("create model file '{$modelFile}' successfully.");
        } else {
            tprintError("Error: create model file '{$modelFile}' faild.");
        }
    }
914525
protected function triggerSql($sql, $runtime, $options = [])
    {
        if (!empty(self::$event)) {
            foreach (self::$event as $callback) {
                if (is_callable($callback)) {
                    call_user_func_array($callback, [$sql, $runtime, $options]);
                }
            }
        } else {
            // 未注册监听则记录到日志中
            $this->logger('[ SQL ] ' . $sql . ' [ RunTime:' . $runtime . 's ]');
        }
    }
431060
public function setCookie(array $options): self
    {
        if (isset($options['name']) && is_string($options['name'])) {
            //正常COOKIE的设定
            $this->cookies->add($options);
        } else {
            if (key($options) === 0) {
                //数组COOKIE的设定
                foreach ($options as $parent_name => $obj) {
                    $obj['name'] = $parent_name . '[' . $obj['name'] . ']';
                    $this->cookies->add($obj);
                }
            }
        }

        return $this;
    }
385857
private function _optionsToString(array $options)
    {
        $str = '';
        foreach ($options as $key => $val) {
            if ($key === 'password')
                $val = '*****';
            if ($str)
                $str .= ',';
            $str .= $key . '=' . $val;
        }
        return $str;
    }
1220531
public static function btnHeader($options = [])
    {
        // Icon
        $icon = ArrayHelper::remove($options, 'icon');
        if ($icon === null) {
            return '';
        }
        $iconOptions = ArrayHelper::remove($options, 'iconOptions', []);
        // Div
        static::addCssClass($options, 'btn-header');
        $position = ArrayHelper::remove($options, 'position', self::PULL_RIGHT);
        if (in_array($position, [self::PULL_LEFT, self::PULL_RIGHT])) {
            static::addCssClass($options, $position);
        }
        // Link
        $linkOptions = ArrayHelper::remove($options, 'linkOptions', []);
        $url = ArrayHelper::remove($linkOptions, 'href', 'javascript:void(0);');
        return static::tag('div', static::tag('span', static::a(static::icon($icon, $iconOptions), $url, $linkOptions)), $options);
    }
1351482
function(options) {
        var title = this.$main.attr('title'),
            id = this.$main.attr('id') || '',
            theme = options.theme;

        var switchContainer = '<label class="' + defaultContainerClass + ' biz-switch-container-' + theme + '" for="' + id + '"><span class="biz-switch" id=""><span class="biz-switch-inner"></span></span><span>' + title + '</span></label>';

        this.$main.after(switchContainer).hide();

        this.$switchContainer = this.$main.next();
        this.$switchDom = this.$switchContainer.find('.biz-switch');
        //初始状态
        if (this.$main.attr('checked')) {
            this.$switchDom.addClass(checkedClass);
        } else {
            this.$switchDom.addClass(defaultClass);
        }

        var self = this;
        this.$switchContainer.on('click.bizSwitch', function() {
            if (!self.main.disabled) {
                if (self.main.checked) {
                    self.$switchDom.attr('class', [defaultClass].join(' '));
                } else {
                    self.$switchDom.attr('class', [defaultClass, checkedClass].join(' '));
                }
                if (id === '') {
                    self.main.checked = !self.main.checked;
                }
            }
        });
    }
1098428
public function objectToString($object, $options = array())
	{
		$bitMask = isset($options['bitmask']) ? $options['bitmask'] : 0;

		// The depth parameter is only present as of PHP 5.5
		if (version_compare(PHP_VERSION, '5.5', '>='))
		{
			$depth = isset($options['depth']) ? $options['depth'] : 512;

			return json_encode($object, $bitMask, $depth);
		}

		return json_encode($object, $bitMask);
	}
1248891
public function getPk($options = '')
    {
        if (!empty($this->pk)) {
            $pk = $this->pk;
        } else {
            $pk = $this->getTableInfo(is_array($options) ? $options['table'] : $options, 'pk');
        }
        return $pk;
    }
5529
public function buildSelectSql($options=array()) {
        if(isset($options['page'])) {
            // 根据页数计算limit
            list($page,$listRows)   =   $options['page'];
            $page    =  $page>0 ? $page : 1;
            $listRows=  $listRows>0 ? $listRows : (is_numeric($options['limit'])?$options['limit']:20);
            $offset  =  $listRows*($page-1);
            $options['limit'] =  $offset.','.$listRows;
        }
        $sql  =   $this->parseSql($this->selectSql,$options);
        return $sql;
    }
1036907
public function crop( array $options = [] ) : Image
	{
		$this->cropOption = empty( $options ) ? $this->cropOption : $options;
		// 裁剪
		$img = ImageManage::make( $this->originFileInfo['path'] );
		foreach( $this->cropOption as $suffix => $option ){
			list( $width, $height ) = $option;
			$img->resize( $width, $height, function( $constraint ){
				$constraint->aspectRatio();
			} );
			// 水印 todo 位置设置 目前是左上角
			if( $this->watermark === true ){
				$img->insert( 'Public/watermark.png' );
			}
			$target_file_name = "{$this->targetFolder}/{$this->fileName}_{$suffix}.{$this->ext}";

			// 生成略显图
			$img->save( $target_file_name );

			// 记录裁剪图片的信息
			$this->cropImages[$suffix] = $this->getImageInfoFormatData( $target_file_name );
		}
		return $this;
	}
1168191
protected function request($uri, array $params = [], array $options = [])
    {
        if ($options) {
            $params = array_merge($params, $options);
        }
        // 没有参数, 设置一个默认参数
        if (!$params) {
            $params['php-etcd-client'] = 1;
        }
        $data = [
            'json' => $params,
        ];
        if ($this->token) {
            $data['headers'] = ['Grpc-Metadata-Token' => $this->token];
        }

        $response = $this->getHttpClient()->request('post', $uri, $data);
        $content = $response->getBody()->getContents();

        $body = json_decode($content, true);
        if ($this->pretty && isset($body['header'])) {
            unset($body['header']);
        }

        return $body;
    }
297425
protected function encodeOptions(array $options) {
        if (0 === count($options)) {
            return "{}";
        }
        ksort($options);
        $output = json_encode($options, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        return str_replace("\n", "\n        ", $output);
    }
437474
public function execute(array $args = [], array $options = [])
    {
        /** @var CommandInterface[] $commands */
        $commands = $this->getConfig()->get('commands');

        $all = isset($options['all']) && true === $options['all'];

        $selectedCommands = [];
        foreach ($commands as $n => $c) {
            $hidden = false;
            $realName = $n;
            if ('_' === $n{0}) {
                if (!$all) {
                    continue;
                }
                $hidden = true;
                $n = substr($n, 1);
            }
            $selectedCommands[$n] = ['hidden' => $hidden, 'realName' => $realName, 'command' => $c];
        }

        ksort($selectedCommands);

        $user = $this->getConfig()->get('user_name');

        if ($user) {
            $this->writeln('<comment>DEV Console command</comment> (Happy hacking %s !)', $user);
        } else {
            $this->writeln('<comment>DEV Console command</comment>');
        }
        $this->writeln();
        $this->writeln('%d commands:', count($selectedCommands));

        $max = 0;

        foreach ($selectedCommands as $commandName => $def) {
            $len = strlen($commandName);
            $max = $max < $len ? $len : $max;
        }

        $lastLetter = null;

        foreach ($selectedCommands as $commandName => $def) {
            $letter = $commandName{0};
            if ($lastLetter !== $letter) {
                $this->writeln();
            }
            /** @var CommandInterface $command */
            $command = $def['command'];
            $command->setConfig($this->getConfig());
            $this->writeln("  <".($def['hidden'] ? 'comment' : 'info').">%-".$max."s</".($def['hidden'] ? 'comment' : 'info').">  <comment>%s</comment>", $commandName, $command->getDescription());
            $lastLetter = $letter;
        }

        $this->writeln();
    }
797221
protected function logError(Http $http, $options = [])
    {
        $this->logger->alert('微信第三方平台业务出错', [
            'options' => $options,
            'status' => $http->getErrorStatus(),
            'response' => $http->getResponseText(),
            'exception' => (string) $http->getErrorException(),
        ]);
    }
598268
protected function assertRequiredOptions($key, array $options)
    {
        $missing = array_diff_key(array_flip($this->getRequiredOptions($key)), $options);
        if (!empty($missing)) {
            throw new \InvalidArgumentException(
                '参数不完整，请指定'.$key.'参数: '.implode(', ', array_keys($missing))
            );
        }
    }
1143832
public function objectToString($object, $options = array())
	{
		if (is_string($object))
		{
			return $object;
		}

		return SymfonyYaml::dump((array) $this->asArray($object), 2);
	}