生成模版数据

@param string $code
@param int    $minutes
@param string $type

@return array
18096
protected function generateTemplateData($code, $minutes, $type)
    {
        $tplData = config('laravel-sms.templateData') ?: config('laravel-sms.data');
        if (is_string($tplData)) {
            $tplData = Util::unserializeClosure($tplData);
        }
        if (is_callable($tplData)) {
            $tplData = call_user_func_array($tplData, [$code, $minutes, $this->input(), $type]);
        }
        if (!is_array($tplData) || empty($tplData)) {
            return [
                'code'    => $code,
                'minutes' => $minutes,
            ];
        }
        foreach ($tplData as $key => $value) {
            if (is_string($value) && preg_match(self::closurePattern, $value)) {
                $value = Util::unserializeClosure($value);
            }
            if (is_callable($value)) {
                $tplData[$key] = call_user_func_array($value, [$code, $minutes, $this->input(), $type]);
            }
        }

        return array_filter($tplData, function ($value) {
            return $value !== null;
        });
    }
340882
protected static function toXpath($code, $type='html', $encoding='UTF-8') {
		$doc = new \DOMDocument();
		if ($type == 'xml')
			@$doc->loadXML('<?xml encoding="'.$encoding.'">' . $code);
		else
			@$doc->loadHTML('<?xml encoding="'.$encoding.'">' . $code);

		foreach($doc->childNodes as $item) {
			if($item->nodeType == XML_PI_NODE)
				$doc->removeChild($item); #remove encoding node
		}

		return new \DOMXPath($doc);
	}
541626
public function getCode($codes, $type)
    {
        foreach ($codes as $code) {
            if ($code->type === $type) {
                return $code->type === 'external_code' ? substr($code->value, 3) : $code->value;
            }
        }

        return;
    }
371367
public static TypeCode toTypeCode(Class<?> type) {
		if (type == null)
			return TypeCode.Unknown;
		else if (type.isArray())
			return TypeCode.Array;
		else if (type.isEnum())
			return TypeCode.Enum;
		else if (type.isPrimitive()) {
			if (_booleanType.isAssignableFrom(type))
				return TypeCode.Boolean;
			if (_doubleType.isAssignableFrom(type))
				return TypeCode.Double;
			if (_floatType.isAssignableFrom(type))
				return TypeCode.Float;
			if (_longType.isAssignableFrom(type))
				return TypeCode.Long;
			if (_integerType.isAssignableFrom(type))
				return TypeCode.Integer;
		} else {
			if (_booleanType.isAssignableFrom(type))
				return TypeCode.Boolean;
			if (_doubleType.isAssignableFrom(type))
				return TypeCode.Double;
			if (_floatType.isAssignableFrom(type))
				return TypeCode.Float;
			if (_longType.isAssignableFrom(type))
				return TypeCode.Long;
			if (_integerType.isAssignableFrom(type))
				return TypeCode.Integer;
			if (_stringType.isAssignableFrom(type))
				return TypeCode.String;
			if (_dateTimeType.isAssignableFrom(type))
				return TypeCode.DateTime;
			if (_durationType.isAssignableFrom(type))
				return TypeCode.Duration;
			if (_mapType.isAssignableFrom(type))
				return TypeCode.Map;
			if (_listType.isAssignableFrom(type))
				return TypeCode.Array;
			if (_enumType.isAssignableFrom(type))
				return TypeCode.Enum;
		}

		return TypeCode.Object;
	}
713705
public static function code( $type, $name = null ) 
	{
		$buffer = "";
		
		foreach( static::holder( $name )->get( $type ) as $item )
		{
			$buffer .= call_user_func( array( '\\CCAsset', $type ), $item, $name );
		}
		
		return $buffer;
	}
590106
public function getData4CodeType($code, $type)
    {
        $query = $this->createQueryBuilder('p')
            ->select('p')
            ->where('p.code = :code')
            ->setParameter('code', $code)
            ->andWhere('p.expire >= :expire')
            ->setParameter('expire', new \DateTime())
            ->andWhere('p.type = :type')
            ->setParameter('type', $type)
            ->getQuery();

        return $query->getOneOrNullResult();
    }
800213
private function getNewExpiresDateString($type = 'short')
	{
		$modifier = $this->config[$type]['period'];
		return with(new Date('now'))->modify('+' . $modifier . ' MINUTES')->toSql();
	}
515359
public function get( $code, $type = null )
	{
		if( isset( $this->prodmap[$code] ) ) {
			return $this->prodmap[$code];
		}

		$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );

		$search = $manager->createSearch();
		$search->setConditions( $search->compare( '==', 'product.code', $code ) );

		$result = $manager->searchItems( $search );

		if( ( $item = reset( $result ) ) !== false )
		{
			$this->prodmap[$code] = $item->getId();
			return $this->prodmap[$code];
		}
	}
1067839
public function put($key, $value, $minutes = 525600)
    {
        $this->getCacheInstance()->put($key, $value, $minutes);

        return $value;
    }
770425
public function get( $code, $type = null )
	{
		if( isset( $this->attributes[$code] ) && isset( $this->attributes[$code][$type] ) ) {
			return $this->attributes[$code][$type];
		}

		$manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );

		$search = $manager->createSearch();
		$expr = array(
			$search->compare( '==', 'attribute.code', $code ),
			$search->compare( '==', 'attribute.type', $type ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

		$result = $manager->searchItems( $search );

		if( ( $item = reset( $result ) ) !== false )
		{
			$this->attributes[$code][$type] = $item;
			return $item;
		}
	}
1303782
protected function response($data,$type='',$code=200) {
        $this->sendHttpStatus($code);
        exit($this->encodeData($data,strtolower($type)));
    }
400547
public function setBarcode($code, $type) {
		$mode = explode(',', $type);
		switch (strtoupper($mode[0])) {
			case 'TEST': { // TEST MODE
				$this->barcode_array['num_rows'] = 5;
				$this->barcode_array['num_cols'] = 15;
				$this->barcode_array['bcode'] = array(
					array(1,1,1,0,1,1,1,0,1,1,1,0,1,1,1),
					array(0,1,0,0,1,0,0,0,1,0,0,0,0,1,0),
					array(0,1,0,0,1,1,0,0,1,1,1,0,0,1,0),
					array(0,1,0,0,1,0,0,0,0,0,1,0,0,1,0),
					array(0,1,0,0,1,1,1,0,1,1,1,0,0,1,0)
				);
				break;
			}
			default: {
				$this->barcode_array = false;
			}
		}
	}
915172
public function put($key, $value, $minutes)
	{
		return $this->engine->set($this->id($key), $value, $minutes * 60);
	}
123017
public function put($key, $value, $minutes)
    {
        if ($minutes <= 0) {
            return;
        }

        $value = $this->expiration($minutes) . serialize($value);

        if (true === $this->has($key)) {
            return dba_replace($key, $value, $this->dba);
        }

        return dba_insert($key, $value, $this->dba);
    }
1332640
final public static function get_header_string(int $code) {
		if (!isset(self::$header_string[$code]))
			$code = 404;
		return [
			'code' => $code,
			'msg'  => self::$header_string[$code],
		];
	}
1342356
public static function createResponse($body, $mediaType = 'text/html', $code = 200)
    {
        return Factory::createResponse()
            ->withStatus($code)
            ->withHeader('Content-Type', $mediaType)
            ->withBody(Factory::createStream($body));
    }
723036
public static function getReason(int $code, string $default = ''): string
    {
        static $reasons = [
            self::CONTINUE => 'Continue',
            self::SWITCHING_PROTOCOLS => 'Switching Protocols',
            self::OK => 'OK',
            self::CREATED => 'Created',
            self::ACCEPTED => 'Accepted',
            self::NON_AUTHORITATIVE_INFORMATION => 'Non-Authoritative Information',
            self::NO_CONTENT => 'No Content',
            self::RESET_CONTENT => 'Reset Content',
            self::PARTIAL_CONTENT => 'Partial Content',
            self::MULTI_STATUS => 'Multi-Status',
            self::MULTIPLE_CHOICES => 'Multiple Choices',
            self::MOVED_PERMANENTLY => 'Moved Permanently',
            self::FOUND => 'Found',
            self::SEE_OTHER => 'See Other',
            self::NOT_MODIFIED => 'Not Modified',
            self::USE_PROXY => 'Use Proxy',
            self::TEMPORARY_REDIRECT => 'Temporary Redirect',
            self::BAD_REQUEST => 'Bad Request',
            self::UNAUTHORIZED => 'Unauthorized',
            self::PAYMENT_REQUIRED => 'Payment Required',
            self::FORBIDDEN => 'Forbidden',
            self::NOT_FOUND => 'Not Found',
            self::METHOD_NOT_ALLOWED => 'Method Not Allowed',
            self::NOT_ACCEPTABLE => 'Not Acceptable',
            self::PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',
            self::REQUEST_TIMEOUT => 'Request Timeout',
            self::CONFLICT => 'Conflict',
            self::GONE => 'Gone',
            self::LENGTH_REQUIRED => 'Length Required',
            self::PRECONDITION_FAILED => 'Precondition Failed',
            self::PAYLOAD_TOO_LARGE => 'Payload Too Large',
            self::REQUEST_URI_TOO_LONG => 'Request-URI Too Long',
            self::UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
            self::REQUEST_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable',
            self::EXPECTATION_FAILED => 'Expectation Failed',
            self::MISDIRECTED_REQUEST => 'Misdirected Request',
            self::UNPROCESSABLE_ENTITY => 'Unprocessable Entity',
            self::LOCKED => 'Locked',
            self::FAILED_DEPENDENCY => 'Failed Dependency',
            self::UPGRADE_REQUIRED => 'Upgrade Required',
            self::PRECONDITION_REQUIRED => 'Precondition Required',
            self::TOO_MANY_REQUESTS => 'Too Many Requests',
            self::REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large',
            self::INTERNAL_SERVER_ERROR => 'Internal Server Error',
            self::NOT_IMPLEMENTED => 'Not Implemented',
            self::BAD_GATEWAY => 'Bad Gateway',
            self::SERVICE_UNAVAILABLE => 'Service Unavailable',
            self::GATEWAY_TIMEOUT => 'Gateway Timeout',
            self::HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version Not Supported',
            self::INSUFFICIENT_STORAGE => 'Insufficient Storage',
            self::BANDWIDTH_LIMIT_EXCEEDED => 'Bandwidth Limit Exceeded',
            self::VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
            self::NOT_EXTENDED => 'Not Extended',
            self::NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required'
        ];
        
        return $reasons[$code] ?? $default;
    }