<?php
/**
 * Copyright (C) php-fn. See LICENSE file for license details.
 */

namespace fn\Map;

use fn;
use Iterator;
use IteratorAggregate;
use IteratorIterator;
use RecursiveArrayIterator;
use Traversable;

/**
 */
class Inner extends IteratorIterator
{
    /**
     * @var array
     */
    private $cache = [];

    /**
     * @var bool
     */
    private $isReset;

    /**
     * @param traversable|array $inner
     */
    public function __construct($inner)
    {
        parent::__construct(self::unify($inner));
    }

    /**
     * @param traversable|array $inner
     *
     * @return RecursiveArrayIterator|Traversable
     */
    private static function unify($inner)
    {
        if ($inner instanceof Iterator) {
            return $inner;
        }

        if (is_array($inner)) {
            return new RecursiveArrayIterator($inner);
        }

        $counter = 0;
        while ($inner instanceof IteratorAggregate) {
            $counter++ > 10 && fn\fail('$inner::getIterator is too deep');
            if (($temp = $inner->getIterator()) === $inner) {
                fn\fail('Implementation $inner::getIterator returns same instance');
            }
            $inner = $temp;
        }

        if ($inner instanceof Traversable && !$inner instanceof Iterator) {
            return $inner;
        }

        $inner instanceof Iterator || fn\fail('Property $inner must be iterable');
        return $inner;
    }

    /**
     * @return bool|null
     */
    public function isLast(): ?bool
    {
        if (!$this->isReset) {
            return null;
        }

        if (!$this->cache) {
            $this->cache = [
                'valid'   => parent::valid(),
                'key'     => parent::key(),
                'current' => parent::current(),
            ];

            parent::valid() && parent::next();
        }
        return $this->cache['valid'] ? !parent::valid() : null;
    }

    /**
     * @inheritdoc
     */
    public function rewind(): void
    {
        $this->isReset = true;
        $this->cache   = [];
        parent::rewind();
    }

    /**
     * @inheritdoc
     */
    public function valid(): bool
    {
        return $this->cache ? $this->cache['valid'] : parent::valid();
    }

    /**
     * @inheritdoc
     */
    public function current()
    {
        return $this->cache ? $this->cache['current'] : parent::current();
    }

    /**
     * @inheritdoc
     */
    public function key()
    {
        return $this->cache ? $this->cache['key'] : parent::key();
    }

    /**
     * @inheritdoc
     */
    public function next(): void
    {
        $this->cache ? $this->cache = [] : parent::next();
    }
}


<?php
/**
 * HTML utilities.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare(strict_types=1);
namespace WebSharks\Core\Classes\Core\Utils;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * HTML utilities.
 *
 * @since 150424 Initial release.
 */
class Html extends Classes\Core\Base\Core
{
    /**
     * Is a string in HTML format?
     *
     * @since 150424 Initial release.
     *
     * @param string $string Any input string to test here.
     * @param bool   $strict Use strict (full DOM) check?
     *
     * @return bool `TRUE` if string is HTML.
     */
    public function is(string $string, bool $strict = false): bool
    {
        if ($strict) {
            return mb_strpos($string, '</html>') !== false;
        }
        return mb_strpos($string, '<') !== false && preg_match('/\<[^<>]+\>/u', $string);
    }

    /**
     * Checked?
     *
     * @since 150424 Initial release.
     *
     * @param mixed $a Input variable a.
     * @param mixed $b Input variable b.
     *
     * @return string ` checked` if true.
     */
    public function checked($a, $b)
    {
        return (string) $a === (string) $b ? ' checked' : '';
    }

    /**
     * Selected?
     *
     * @since 150424 Initial release.
     *
     * @param mixed $a Input variable a.
     * @param mixed $b Input variable b.
     *
     * @return string ` selected` if true.
     */
    public function selected($a, $b)
    {
        return (string) $a === (string) $b ? ' selected' : '';
    }

    /**
     * Active?
     *
     * @since 150424 Initial release.
     *
     * @param mixed $a Input variable a.
     * @param mixed $b Input variable b.
     *
     * @return string ` active` if true.
     */
    public function active($a, $b)
    {
        return (string) $a === (string) $b ? ' active' : '';
    }

    /**
     * Active & selected?
     *
     * @since 170413.34876 Initial release.
     *
     * @param mixed $a Input variable a.
     * @param mixed $b Input variable b.
     *
     * @return string ` active selected` if true.
     */
    public function activeSelected($a, $b)
    {
        return (string) $a === (string) $b ? ' active selected' : '';
    }
}


<?php
/**
 * PDO utilities.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare(strict_types=1);
namespace WebSharks\Core\Classes\Core\Utils;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * PDO utilities.
 *
 * @since 150424 Initial release.
 */
class Pdo extends Classes\Core\Base\Core
{
    /**
     * Current PDO.
     *
     * @since 150424
     *
     * @type \PDO|null
     */
    public $current;

    /**
     * Constructor.
     *
     * @since 150424 Initial release.
     *
     * @param Classes\App $App Instance of App.
     */
    public function __construct(Classes\App $App)
    {
        parent::__construct($App);

        if (!class_exists('PDO')) {
            throw $this->c::issue('Missing PDO extension for PHP.');
        }
    }

    /**
     * Quotes/escapes SQL value.
     *
     * @since 160422 SQL utils.
     *
     * @param int|float|string $value Value.
     *
     * @return string Quoted/escaped value (as a string).
     */
    public function quote($value): string
    {
        if (!($Pdo = $this->current)) {
            throw $this->c::issue('No PDO yet; i.e., unable to quote.');
        }
        switch (gettype($value)) {
            case 'int':
            case 'integer':
                return $Pdo->quote((string) $value, $Pdo::PARAM_INT);

            case 'float':
            case 'double':
                return $Pdo->quote((string) $value, $Pdo::PARAM_STR);

            case 'str':
            case 'string':
                return $Pdo->quote($value, $Pdo::PARAM_STR);

            default: // Unexpected data type.
                throw $this->c::issue('Unexpected data type; unable to quote.');
        }
    }

    /**
     * PDO instance for a DB.
     *
     * @since 150424 Initial release.
     * @since 17xxxx Additional arg/types.
     *
     * @param int|string|null $shard_id_or_host     Shard ID or DB host.
     * @param int|string|null $uuid_or_host_db_name UUID64 or host DB name.
     *
     * @return \PDO A PDO class instance.
     */
    public function get($shard_id_or_host = null, $uuid_or_host_db_name = null): \PDO
    {
        // Acquire DB configuration details.

        $db = $this->dbConfig($shard_id_or_host, $uuid_or_host_db_name);

        // Are we already connected to this host?

        if (($Pdo = &$this->cacheKey(__FUNCTION__, $db['©host']))) {
            if (empty($Pdo->db_name) || $Pdo->db_name !== $db['©name']) {
                $Pdo->exec('use `'.$db['©name'].'`');
                $Pdo->db_name = $db['©name'];
            }
            return $this->current = $Pdo;
        }
        // Otherwise, we need to establish a new connection.

        if (empty($this->App->Config->©mysql_db['©hosts'][$db['©host']])) {
            throw $this->c::issue(sprintf('Missing DB host: `%1$s`.', $db['©host']));
        }
        $db_host         = $this->App->Config->©mysql_db['©hosts'][$db['©host']];
        $db_host_options = [
            \PDO::ATTR_TIMEOUT => 5,

            \PDO::ATTR_AUTOCOMMIT       => true,
            \PDO::ATTR_EMULATE_PREPARES => false,

            \PDO::ATTR_CASE               => \PDO::CASE_NATURAL,
            \PDO::ATTR_ORACLE_NULLS       => \PDO::NULL_NATURAL,
            \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ,

            \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
            \PDO::ATTR_ERRMODE                  => \PDO::ERRMODE_EXCEPTION,
        ];
        if ($db_host['©charset']) { // Use a specific charset?
            $db_host_options[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES \''.$db_host['©charset'].'\'';

            if ($db_host['©collate']) { // Also a specific collation?
                $db_host_options[\PDO::MYSQL_ATTR_INIT_COMMAND] .= ' COLLATE \''.$db_host['©collate'].'\'';
            }
        }
        if ($db_host['©ssl_enable'] && $db_host['©ssl_key'] && $db_host['©ssl_crt'] && $db_host['©ssl_ca'] && $db_host['©ssl_cipher']) {
            $db_host_options[\PDO::MYSQL_ATTR_SSL_KEY]    = $db_host['©ssl_key'];
            $db_host_options[\PDO::MYSQL_ATTR_SSL_CERT]   = $db_host['©ssl_crt'];
            $db_host_options[\PDO::MYSQL_ATTR_SSL_CA]     = $db_host['©ssl_ca'];
            $db_host_options[\PDO::MYSQL_ATTR_SSL_CIPHER] = $db_host['©ssl_cipher'];
        }
        $Pdo = new \PDO('mysql:host='.$db['©host'].';port='.$db_host['©port'], $db_host['©username'], $db_host['©password'], $db_host_options);

        $Pdo->exec('use `'.$db['©name'].'`');
        $Pdo->db_name         = $db['©name'];
        return $this->current = $Pdo;
    }

    /**
     * DB config properties.
     *
     * @since 150424 Initial release.
     * @since 17xxxx Additional arg/types.
     *
     * @param int|string|null $shard_id_or_host     Shard ID or DB host.
     * @param int|string|null $uuid_or_host_db_name UUID64 or host DB name.
     *
     * @return array DB config properties.
     */
    protected function dbConfig($shard_id_or_host = null, $uuid_or_host_db_name = null): array
    {
        $cache_keys = [$shard_id_or_host, $uuid_or_host_db_name];

        if (($properties = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null) {
            return $properties; // Cached this already.
        }
        if (!isset($shard_id_or_host)) {
            $shard_id_or_host = is_int($uuid_or_host_db_name)
                ? $this->c::uuid64ShardIdIn($uuid_or_host_db_name)
                : $this->App->Config->©mysql_db['©default']['©host'];
        }
        if (!isset($uuid_or_host_db_name) && is_string($shard_id_or_host)) {
            $uuid_or_host_db_name = $this->App->Config->©mysql_db['©default']['©name'];
        }
        if (is_int($shard_id = $shard_id_or_host) && $shard_id >= 0) {
            foreach ($this->App->Config->©mysql_db['©shards'] as $_key => $_shard_db) {
                if ($shard_id >= $_shard_db['©range']['©from'] && $shard_id <= $_shard_db['©range']['©to']) {
                    return $properties = $_shard_db['©properties'];
                }
            } // unset($_key, $_shard_db);
        } elseif (is_string($host = $shard_id_or_host) && is_string($host_db_name) && $host && $host_db_name) {
            return $properties = ['©host' => $host, '©name' => $host_db_name];
        }
        throw $this->c::issue(sprintf('Missing DB config for: `%1$s`, `%2$s`.', $shard_id_or_host, $uuid_or_host_db_name));
    }
}


<?php
/**
 * UUID 64 parser/builder.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare (strict_types = 1);
namespace WebSharks\Core\Classes\Core\Utils;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * UUID 64 parser/builder.
 *
 * @since 150424 Initial release.
 */
class Uuid64 extends Classes\Core\Base\Core
{
    /**
     * UUID64 validator.
     *
     * @since 150424 Initial release.
     *
     * @param int      $uuid              Input UUID64 (64 bits signed max `9223372036854775807`).
     * @param int|null $expecting_type_id Expected type ID.
     *
     * @return int Validated UUID64 (64-bits signed max `9223372036854775807`).
     */
    public function validate(int $uuid, int $expecting_type_id = null): int
    {
        if ($uuid < 1 || $uuid > 9223372036854775807) {
            throw $this->c::issue('UUID64 out of range.');
        }
        if (isset($expecting_type_id)) {
            $this->typeIdIn($uuid, $expecting_type_id);
        }
        return $uuid;
    }

    /**
     * Shard ID from UUID64.
     *
     * @since 150424 Initial release.
     *
     * @param int  $uuid     Input UUID64 (64 bits signed max `9223372036854775807`).
     * @param bool $validate Validate the shard ID after extraction? Defaults to `true`.
     *
     * @return int Shard ID from UUID64 (16 bits unsigned max `65535`).
     */
    public function shardIdIn(int $uuid, bool $validate = true): int
    {
        $shard_id = ($uuid >> (64 - 2 - 16)) & 65535;

        if ($validate) {
            $this->validateShardId($shard_id);
        }
        return $shard_id;
    }

    /**
     * Validate shard ID.
     *
     * @since 150424 Initial release.
     *
     * @param int $shard_id Input shard ID (16 bits unsigned max `65535`).
     *
     * @return int Validated shard ID (16 bits unsigned max `65535`).
     */
    public function validateShardId(int $shard_id): int
    {
        if ($shard_id < 0 || $shard_id > 65535) {
            throw $this->c::issue('Shard ID out of range.');
        }
        return $shard_id;
    }

    /**
     * Type ID from UUID64.
     *
     * @since 150424 Initial release.
     *
     * @param int      $uuid              Input UUID64 (64 bits signed max `9223372036854775807`).
     * @param int|null $expecting_type_id Expected type ID; i.e., validate for this type ID?
     * @param bool     $validate          Validate the type ID after extraction? Defaults to `true`.
     *
     * @return int Type ID from UUID64 (8 bits unsigned max `255`).
     */
    public function typeIdIn(int $uuid, int $expecting_type_id = null, bool $validate = true): int
    {
        $type_id = ($uuid >> (64 - 2 - 16 - 8)) & 255;

        if (isset($expecting_type_id)) {
            $this->validateTypeId($type_id, $expecting_type_id);
        } elseif ($validate) {
            $this->validateTypeId($type_id);
        }
        return $type_id;
    }

    /**
     * Validate type ID.
     *
     * @since 150424 Initial release.
     *
     * @param int      $type_id           Input type ID (8 bits unsigned max `255`).
     * @param int|null $expecting_type_id Expected type ID.
     *
     * @return int Validated type ID (8 bits unsigned max `255`).
     */
    public function validateTypeId(int $type_id, int $expecting_type_id = null): int
    {
        if ($type_id < 0 || $type_id > 255) {
            throw $this->c::issue('Type ID out of range.');
        } elseif (isset($expecting_type_id) && $type_id !== $expecting_type_id) {
            throw $this->c::issue(sprintf('Type ID mismatch: `%1$s`/`%2$s`.', $type_id, $expecting_type_id));
        }
        return $type_id;
    }

    /**
     * Local ID from UUID64.
     *
     * @since 150424 Initial release.
     *
     * @param int  $uuid     Input UUID64 (64 bits signed max `9223372036854775807`).
     * @param bool $validate Validate the local ID after extraction? Defaults to `true`.
     *
     * @return int Local ID from UUID64 (38 bits unsigned max `274877906943`).
     */
    public function localIdIn(int $uuid, bool $validate = true): int
    {
        $local_id = ($uuid >> (64 - 2 - 16 - 8 - 38)) & 274877906943;

        if ($validate) {
            $this->validateLocalId($local_id);
        }
        return $local_id;
    }

    /**
     * Validate local ID.
     *
     * @since 150424 Initial release.
     *
     * @param int $local_id Input local ID (38 bits unsigned max `274877906943`).
     *
     * @return int Validated local ID (38 bits unsigned max `274877906943`).
     */
    public function validateLocalId(int $local_id): int
    {
        if ($local_id < 1 || $local_id > 274877906943) {
            throw $this->c::issue('Local ID out of range.');
        }
        return $local_id;
    }

    /**
     * UUID64 parser.
     *
     * @since 150424 Initial release.
     *
     * @param int      $uuid              Input UUID64 (64 bits signed max `9223372036854775807`).
     * @param int|null $expecting_type_id Expected type ID; i.e., validate this type ID?
     * @param bool     $validate          Validate the UUID and each part?
     *
     * @return array IDs: `shard_id`, `type_id`, `local_id` from UUID64.
     *
     *               - `shard_id` (16 bits unsigned max `65535`).
     *               - `type_id` (8 bits unsigned max `255`).
     *               - `local_id` (38 bits unsigned max `274877906943`).
     */
    public function parse(int $uuid, int $expecting_type_id = null, bool $validate = true): array
    {
        if ($validate) {
            $this->validate($uuid);
        }
        $shard_id = $this->shardIdIn($uuid, $validate);
        $type_id  = $this->typeIdIn($uuid, $expecting_type_id, $validate);
        $local_id = $this->localIdIn($uuid, $validate);

        return compact('shard_id', 'type_id', 'local_id');
    }

    /**
     * UUID64 builder.
     *
     * @since 150424 Initial release.
     *
     * @param int  $shard_id Shard ID (16 bits unsigned max `65535`).
     * @param int  $type_id  Type ID (8 bits unsigned max `255`).
     * @param int  $local_id Local ID (38 bits unsigned max `274877906943`).
     * @param bool $validate Validate each of the IDs first? Defaults to `true`.
     *
     * @return int UUID64 (64 bits signed max `9223372036854775807`).
     *
     *             - (2 reserve bits; set to a value of 0).
     *             - `shard_id` (16 bits unsigned max `65535`).
     *             - `type_id` (8 bits unsigned max `255`).
     *             - `local_id` (38 bits unsigned max `274877906943`).
     *
     *             = 64 bits signed max: `9223372036854775807` = `PHP_INT_MAX`.
     */
    public function build(int $shard_id, int $type_id, int $local_id, bool $validate = true): int
    {
        if ($validate) {
            $this->validateShardId($shard_id);
            $this->validateTypeId($type_id);
            $this->validateLocalId($local_id);
        }
        return (0 << (64 - 2))
            | ($shard_id << (64 - 2 - 16))
            | ($type_id << (64 - 2 - 16 - 8))
            | ($local_id << (64 - 2 - 16 - 8 - 38));
    }
}


<?php
namespace Perry\Representation\Eve\v2;

use \Perry\Representation\Reference as Reference;
use \Perry\Representation\Uri as Uri;
use \Perry\Representation\Base as Base;

class TournamentRealtimeMatchFrame extends Base
{
    public $redTeamShipData = [];

    public $blueTeamShipData = [];

    public $blueTeamFleetAttributes;

    public $frameNum;

    public $tidiFactor;

    public $time;

    public $redTeamFleetAttributes;

    public $prevFrame;

    public $nextFrame;

    // by Warringer\Types\ArrayType
    public function setRedTeamShipData($redTeamShipData)
    {
        // by Warringer\Types\Base
        $converters = [];
        $converters['physicsData'] = function ($value) { return $value; };
        $converters['missiles'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['itemID'] = function ($value) { return $value; };
        $converters['physicsData'] = function ($value) { return $value; };
        $converters['type'] = function ($value) { return new Reference($value); };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['itemID'] = isset($value->{'itemID'}) ? $converters['itemID']($value->{'itemID'}) : null;
            $return['physicsData'] = isset($value->{'physicsData'}) ? $converters['physicsData']($value->{'physicsData'}) : null;
            $return['type'] = isset($value->{'type'}) ? $converters['type']($value->{'type'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['shield'] = function ($value) { return $value; };
        $converters['itemRef'] = function ($value) { return new Reference($value); };
        $converters['armor'] = function ($value) { return $value; };
        $converters['effects'] = function ($values) {
        // by Warringer\Types\Base
        $converters = [];
        $converters['ammoGraphicResource'] = function ($value) { return new Reference($value); };
        $converters['targetID'] = function ($value) { return $value; };
        $converters['modules'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['moduleID'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['moduleID'] = isset($value->{'moduleID'}) ? $converters['moduleID']($value->{'moduleID'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['effectName'] = function ($value) { return $value; };
        $converters['startTime'] = function ($value) { return $value; };
        $converters['duration'] = function ($value) { return $value; };
        $converters['guid'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['ammoGraphicResource'] = isset($value->{'ammoGraphicResource'}) ? $converters['ammoGraphicResource']($value->{'ammoGraphicResource'}) : null;
            $return['targetID'] = isset($value->{'targetID'}) ? $converters['targetID']($value->{'targetID'}) : null;
            $return['modules'] = isset($value->{'modules'}) ? $converters['modules']($value->{'modules'}) : null;
            $return['effectName'] = isset($value->{'effectName'}) ? $converters['effectName']($value->{'effectName'}) : null;
            $return['startTime'] = isset($value->{'startTime'}) ? $converters['startTime']($value->{'startTime'}) : null;
            $return['duration'] = isset($value->{'duration'}) ? $converters['duration']($value->{'duration'}) : null;
            $return['guid'] = isset($value->{'guid'}) ? $converters['guid']($value->{'guid'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['drones'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['itemID'] = function ($value) { return $value; };
        $converters['physicsData'] = function ($value) { return $value; };
        $converters['type'] = function ($value) { return new Reference($value); };
        $converters['effects'] = function ($values) {
        // by Warringer\Types\Base
        $converters = [];
        $converters['ammoGraphicResource'] = function ($value) { return new Reference($value); };
        $converters['targetID'] = function ($value) { return $value; };
        $converters['modules'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['moduleID'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['moduleID'] = isset($value->{'moduleID'}) ? $converters['moduleID']($value->{'moduleID'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['effectName'] = function ($value) { return $value; };
        $converters['startTime'] = function ($value) { return $value; };
        $converters['duration'] = function ($value) { return $value; };
        $converters['guid'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['ammoGraphicResource'] = isset($value->{'ammoGraphicResource'}) ? $converters['ammoGraphicResource']($value->{'ammoGraphicResource'}) : null;
            $return['targetID'] = isset($value->{'targetID'}) ? $converters['targetID']($value->{'targetID'}) : null;
            $return['modules'] = isset($value->{'modules'}) ? $converters['modules']($value->{'modules'}) : null;
            $return['effectName'] = isset($value->{'effectName'}) ? $converters['effectName']($value->{'effectName'}) : null;
            $return['startTime'] = isset($value->{'startTime'}) ? $converters['startTime']($value->{'startTime'}) : null;
            $return['duration'] = isset($value->{'duration'}) ? $converters['duration']($value->{'duration'}) : null;
            $return['guid'] = isset($value->{'guid'}) ? $converters['guid']($value->{'guid'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['itemID'] = isset($value->{'itemID'}) ? $converters['itemID']($value->{'itemID'}) : null;
            $return['physicsData'] = isset($value->{'physicsData'}) ? $converters['physicsData']($value->{'physicsData'}) : null;
            $return['type'] = isset($value->{'type'}) ? $converters['type']($value->{'type'}) : null;
            $return['effects'] = isset($value->{'effects'}) ? $converters['effects']($value->{'effects'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['structure'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['physicsData'] = isset($value->{'physicsData'}) ? $converters['physicsData']($value->{'physicsData'}) : null;
            $return['missiles'] = isset($value->{'missiles'}) ? $converters['missiles']($value->{'missiles'}) : null;
            $return['shield'] = isset($value->{'shield'}) ? $converters['shield']($value->{'shield'}) : null;
            $return['itemRef'] = isset($value->{'itemRef'}) ? $converters['itemRef']($value->{'itemRef'}) : null;
            $return['armor'] = isset($value->{'armor'}) ? $converters['armor']($value->{'armor'}) : null;
            $return['effects'] = isset($value->{'effects'}) ? $converters['effects']($value->{'effects'}) : null;
            $return['drones'] = isset($value->{'drones'}) ? $converters['drones']($value->{'drones'}) : null;
            $return['structure'] = isset($value->{'structure'}) ? $converters['structure']($value->{'structure'}) : null;
            return $return;
        };

        foreach ($redTeamShipData as $key => $value) {
            $this->redTeamShipData[$key] = $func($value);
        }
    }

    // by Warringer\Types\ArrayType
    public function setBlueTeamShipData($blueTeamShipData)
    {
        // by Warringer\Types\Base
        $converters = [];
        $converters['physicsData'] = function ($value) { return $value; };
        $converters['missiles'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['itemID'] = function ($value) { return $value; };
        $converters['physicsData'] = function ($value) { return $value; };
        $converters['type'] = function ($value) { return new Reference($value); };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['itemID'] = isset($value->{'itemID'}) ? $converters['itemID']($value->{'itemID'}) : null;
            $return['physicsData'] = isset($value->{'physicsData'}) ? $converters['physicsData']($value->{'physicsData'}) : null;
            $return['type'] = isset($value->{'type'}) ? $converters['type']($value->{'type'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['shield'] = function ($value) { return $value; };
        $converters['itemRef'] = function ($value) { return new Reference($value); };
        $converters['armor'] = function ($value) { return $value; };
        $converters['effects'] = function ($values) {
        // by Warringer\Types\Base
        $converters = [];
        $converters['ammoGraphicResource'] = function ($value) { return new Reference($value); };
        $converters['targetID'] = function ($value) { return $value; };
        $converters['modules'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['moduleID'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['moduleID'] = isset($value->{'moduleID'}) ? $converters['moduleID']($value->{'moduleID'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['effectName'] = function ($value) { return $value; };
        $converters['startTime'] = function ($value) { return $value; };
        $converters['duration'] = function ($value) { return $value; };
        $converters['guid'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['ammoGraphicResource'] = isset($value->{'ammoGraphicResource'}) ? $converters['ammoGraphicResource']($value->{'ammoGraphicResource'}) : null;
            $return['targetID'] = isset($value->{'targetID'}) ? $converters['targetID']($value->{'targetID'}) : null;
            $return['modules'] = isset($value->{'modules'}) ? $converters['modules']($value->{'modules'}) : null;
            $return['effectName'] = isset($value->{'effectName'}) ? $converters['effectName']($value->{'effectName'}) : null;
            $return['startTime'] = isset($value->{'startTime'}) ? $converters['startTime']($value->{'startTime'}) : null;
            $return['duration'] = isset($value->{'duration'}) ? $converters['duration']($value->{'duration'}) : null;
            $return['guid'] = isset($value->{'guid'}) ? $converters['guid']($value->{'guid'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['drones'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['itemID'] = function ($value) { return $value; };
        $converters['physicsData'] = function ($value) { return $value; };
        $converters['type'] = function ($value) { return new Reference($value); };
        $converters['effects'] = function ($values) {
        // by Warringer\Types\Base
        $converters = [];
        $converters['ammoGraphicResource'] = function ($value) { return new Reference($value); };
        $converters['targetID'] = function ($value) { return $value; };
        $converters['modules'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['moduleID'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['moduleID'] = isset($value->{'moduleID'}) ? $converters['moduleID']($value->{'moduleID'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['effectName'] = function ($value) { return $value; };
        $converters['startTime'] = function ($value) { return $value; };
        $converters['duration'] = function ($value) { return $value; };
        $converters['guid'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['ammoGraphicResource'] = isset($value->{'ammoGraphicResource'}) ? $converters['ammoGraphicResource']($value->{'ammoGraphicResource'}) : null;
            $return['targetID'] = isset($value->{'targetID'}) ? $converters['targetID']($value->{'targetID'}) : null;
            $return['modules'] = isset($value->{'modules'}) ? $converters['modules']($value->{'modules'}) : null;
            $return['effectName'] = isset($value->{'effectName'}) ? $converters['effectName']($value->{'effectName'}) : null;
            $return['startTime'] = isset($value->{'startTime'}) ? $converters['startTime']($value->{'startTime'}) : null;
            $return['duration'] = isset($value->{'duration'}) ? $converters['duration']($value->{'duration'}) : null;
            $return['guid'] = isset($value->{'guid'}) ? $converters['guid']($value->{'guid'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['itemID'] = isset($value->{'itemID'}) ? $converters['itemID']($value->{'itemID'}) : null;
            $return['physicsData'] = isset($value->{'physicsData'}) ? $converters['physicsData']($value->{'physicsData'}) : null;
            $return['type'] = isset($value->{'type'}) ? $converters['type']($value->{'type'}) : null;
            $return['effects'] = isset($value->{'effects'}) ? $converters['effects']($value->{'effects'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['structure'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['physicsData'] = isset($value->{'physicsData'}) ? $converters['physicsData']($value->{'physicsData'}) : null;
            $return['missiles'] = isset($value->{'missiles'}) ? $converters['missiles']($value->{'missiles'}) : null;
            $return['shield'] = isset($value->{'shield'}) ? $converters['shield']($value->{'shield'}) : null;
            $return['itemRef'] = isset($value->{'itemRef'}) ? $converters['itemRef']($value->{'itemRef'}) : null;
            $return['armor'] = isset($value->{'armor'}) ? $converters['armor']($value->{'armor'}) : null;
            $return['effects'] = isset($value->{'effects'}) ? $converters['effects']($value->{'effects'}) : null;
            $return['drones'] = isset($value->{'drones'}) ? $converters['drones']($value->{'drones'}) : null;
            $return['structure'] = isset($value->{'structure'}) ? $converters['structure']($value->{'structure'}) : null;
            return $return;
        };

        foreach ($blueTeamShipData as $key => $value) {
            $this->blueTeamShipData[$key] = $func($value);
        }
    }

    // by Warringer\Types\Dict
    public function setBlueTeamFleetAttributes($blueTeamFleetAttributes)
    {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['totalEHP'] = function ($value) { return $value; };
        $converters['maxControl'] = function ($value) { return $value; };
        $converters['totalReps'] = function ($value) { return $value; };
        $converters['appliedDPS'] = function ($value) { return $value; };
        $converters['appliedControl'] = function ($value) { return $value; };
        $converters['maxDPS'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['totalEHP'] = isset($value->{'totalEHP'}) ? $converters['totalEHP']($value->{'totalEHP'}) : null;
            $return['maxControl'] = isset($value->{'maxControl'}) ? $converters['maxControl']($value->{'maxControl'}) : null;
            $return['totalReps'] = isset($value->{'totalReps'}) ? $converters['totalReps']($value->{'totalReps'}) : null;
            $return['appliedDPS'] = isset($value->{'appliedDPS'}) ? $converters['appliedDPS']($value->{'appliedDPS'}) : null;
            $return['appliedControl'] = isset($value->{'appliedControl'}) ? $converters['appliedControl']($value->{'appliedControl'}) : null;
            $return['maxDPS'] = isset($value->{'maxDPS'}) ? $converters['maxDPS']($value->{'maxDPS'}) : null;
            return $return;
        };
        $this->blueTeamFleetAttributes = $func($blueTeamFleetAttributes);
    }

    // by Warringer\Types\Long
    public function setFrameNum($frameNum)
    {
        $this->frameNum = $frameNum;
    }

    // by Warringer\Types\Base
    public function setTidiFactor($tidiFactor)
    {
        $this->tidiFactor = $tidiFactor;
    }

    // by Warringer\Types\Long
    public function setTime($time)
    {
        $this->time = $time;
    }

    // by Warringer\Types\Dict
    public function setRedTeamFleetAttributes($redTeamFleetAttributes)
    {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['totalEHP'] = function ($value) { return $value; };
        $converters['maxControl'] = function ($value) { return $value; };
        $converters['totalReps'] = function ($value) { return $value; };
        $converters['appliedDPS'] = function ($value) { return $value; };
        $converters['appliedControl'] = function ($value) { return $value; };
        $converters['maxDPS'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['totalEHP'] = isset($value->{'totalEHP'}) ? $converters['totalEHP']($value->{'totalEHP'}) : null;
            $return['maxControl'] = isset($value->{'maxControl'}) ? $converters['maxControl']($value->{'maxControl'}) : null;
            $return['totalReps'] = isset($value->{'totalReps'}) ? $converters['totalReps']($value->{'totalReps'}) : null;
            $return['appliedDPS'] = isset($value->{'appliedDPS'}) ? $converters['appliedDPS']($value->{'appliedDPS'}) : null;
            $return['appliedControl'] = isset($value->{'appliedControl'}) ? $converters['appliedControl']($value->{'appliedControl'}) : null;
            $return['maxDPS'] = isset($value->{'maxDPS'}) ? $converters['maxDPS']($value->{'maxDPS'}) : null;
            return $return;
        };
        $this->redTeamFleetAttributes = $func($redTeamFleetAttributes);
    }

    // by Warringer\Types\Reference
    public function setPrevFrame($prevFrame)
    {
        $this->prevFrame = new Reference($prevFrame);
    }

    // by Warringer\Types\Reference
    public function setNextFrame($nextFrame)
    {
        $this->nextFrame = new Reference($nextFrame);
    }

}


<?php
declare(strict_types=1);

namespace RabbitCMS\Modules;

use RabbitCMS\Modules\Contracts\PackageContract;
use RabbitCMS\Modules\Support\Facade\Modules;
use Illuminate\Contracts\View\View as ViewContract;
use Illuminate\Support\Facades\View as ViewFacade;

/**
 * Class Module.
 */
class Module implements PackageContract
{
    /**
     * Module path.
     *
     * @var string
     */
    protected $path;

    /**
     * Module name.
     *
     * @var string
     */
    protected $name;

    /**
     * Module description.
     *
     * @var string
     */
    protected $description;

    /**
     * Module namespace.
     *
     * @var string
     */
    protected $namespace;

    /**
     * Module enabled.
     *
     * @var bool
     */
    protected $enabled;

    /**
     * Module providers.
     *
     * @var string[]
     */
    protected $providers;

    /**
     * @var bool
     */
    protected $system;

    /**
     * Module constructor.
     *
     * @param array $options
     */
    public function __construct(array $options)
    {
        $this->path = $options['path'];
        $this->namespace = $options['namespace'];
        $this->name = array_key_exists('name', $options) ? $options['name'] : basename($this->path);
        $this->description = array_key_exists('description', $options) ? $options['description'] : '';
        $this->enabled = array_key_exists('enabled', $options) ? $options['enabled'] : true;
        $this->providers = array_key_exists('providers', $options) ? (array)$options['providers'] : [];
        $this->system = array_key_exists('system', $options) ? $options['system'] : false;
    }

    /**
     * Get module name.
     *
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * Get module namespace.
     */
    public function getNamespace(): string
    {
        return $this->namespace;
    }

    /**
     * @return bool
     */
    public function isEnabled(): bool
    {
        return $this->enabled;
    }

    /**
     * Set enabled module.
     *
     * @param bool $value
     */
    public function setEnabled(bool $value = true)
    {
        $this->enabled = $value;
    }

    /**
     * @return bool
     */
    public function isSystem(): bool
    {
        return $this->system;
    }

    /**
     * Get module path.
     *
     * @param string $path
     *
     * @return string
     */
    public function getPath(string $path = ''): string
    {
        return $this->path . ($path ? '/' . $path : '');
    }

    /**
     * Get modules providers.
     *
     * @return string[]
     */
    public function getProviders(): array
    {
        return $this->providers;
    }

    /**
     * @inheritdoc
     */
    public function toArray(): array
    {
        return [
            'path'        => $this->path,
            'name'        => $this->name,
            'description' => $this->description,
            'namespace'   => $this->namespace,
            'enabled'     => $this->enabled,
            'providers'   => $this->providers,
            'system'      => $this->system,
        ];
    }

    /**
     * Get module description.
     *
     * @return string
     */
    public function getDescription(): string
    {
        return $this->description;
    }

    /**
     * Get the specified configuration value.
     *
     * @param  string $key
     * @param  mixed  $default
     *
     * @return mixed
     */
    public function config(string $key, $default = null)
    {
        return app('config')->get("module.{$this->getName()}.{$key}", $default);
    }

    /**
     * @param string    $path
     * @param bool|null $secure
     *
     * @return string
     */
    public function asset(string $path, ?bool $secure = null): string
    {
        return Modules::asset($this, $path, $secure);
    }

    /**
     * @param string $key
     * @param array  $parameters
     * @param null   $locale
     *
     * @return array|null|string
     */
    public function trans(string $key, array $parameters = [], $locale = null)
    {
        return trans($this->getName() . '::' . $key, $parameters, $locale);
    }

    /**
     * @param string $view
     * @param array  $data
     *
     * @return ViewContract
     */
    public function view(string $view, array $data = []): ViewContract
    {
        return ViewFacade::make($this->viewName($view), $data, []);
    }

    /**
     * Get module view name.
     *
     * @param string $view
     *
     * @return string
     */
    public function viewName($view): string
    {
        return $this->getName() . '::' . $view;
    }
}


<?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) Eric GELOEN <geloen.eric@gmail.com>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Helper\Overlays;

use Ivory\GoogleMap\Helper\AbstractHelper;
use Ivory\GoogleMap\Map;
use Ivory\GoogleMap\Overlays\Polyline;

/**
 * Polyline helper.
 *
 * @author GeLo <geloen.eric@gmail.com>
 */
class PolylineHelper extends AbstractHelper
{
    /**
     * Renders a polyline.
     *
     * @param \Ivory\GoogleMap\Overlays\Polyline $polyline The polyline.
     * @param \Ivory\GoogleMap\Map               $map      The map.
     *
     * @return string The JS output.
     */
    public function render(Polyline $polyline, Map $map)
    {
        $this->jsonBuilder
            ->reset()
            ->setValue('[map]', $map->getJavascriptVariable(), false)
            ->setValue('[path]', array());

        foreach ($polyline->getCoordinates() as $index => $coordinate) {
            $this->jsonBuilder->setValue(sprintf('[path][%d]', $index), $coordinate->getJavascriptVariable(), false);
        }

        $this->jsonBuilder->setValues($polyline->getOptions());

        return sprintf(
            '%s = new google.maps.Polyline(%s);'.PHP_EOL,
            $polyline->getJavascriptVariable(),
            $this->jsonBuilder->build()
        );
    }
}


<?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) Eric GELOEN <geloen.eric@gmail.com>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Overlays;

use Ivory\GoogleMap\Assets\AbstractOptionsAsset;
use Ivory\GoogleMap\Base\Coordinate;
use Ivory\GoogleMap\Exception\OverlayException;

/**
 * Circle which describes a google map circle.
 *
 * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Circle
 * @author GeLo <geloen.eric@gmail.com>
 */
class Circle extends AbstractOptionsAsset implements ExtendableInterface
{
    /** @var \Ivory\GoogleMap\Base\Coordinate */
    protected $center;

    /** @var double */
    protected $radius;

    /**
     * Create a circle.
     *
     * @param \Ivory\GoogleMap\Base\Coordinate $center The circle center.
     * @param double                           $radius The circle radius.
     */
    public function __construct(Coordinate $center = null, $radius = 1)
    {
        parent::__construct();

        $this->setPrefixJavascriptVariable('circle_');

        if ($center === null) {
            $center = new Coordinate();
        }

        $this->setCenter($center);
        $this->setRadius($radius);
    }

    /**
     * Gets the circle center.
     *
     * @return \Ivory\GoogleMap\Base\Coordinate The circle center.
     */
    public function getCenter()
    {
        return $this->center;
    }

    /**
     * Sets the circle center.
     *
     * Available prototypes:
     *  - function setCenter(Ivory\GoogleMap\Base\Coordinate $center)
     *  - function setCenter(double $latitude, double $longitude, boolean $noWrap = true)
     *
     * @throws \Ivory\GoogleMap\Exception\OverlayException If the center is not valid (prototypes).
     */
    public function setCenter()
    {
        $args = func_get_args();

        if (isset($args[0]) && ($args[0] instanceof Coordinate)) {
            $this->center = $args[0];
        } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) {
            $this->center->setLatitude($args[0]);
            $this->center->setLongitude($args[1]);

            if (isset($args[2]) && is_bool($args[2])) {
                $this->center->setNoWrap($args[2]);
            }
        } else {
            throw OverlayException::invalidCircleCenter();
        }
    }

    /**
     * Gets the circle radius.
     *
     * @return double The circle radius.
     */
    public function getRadius()
    {
        return $this->radius;
    }

    /**
     * Sets the circle radius.
     *
     * @param double $radius The circle radius.
     *
     * @throws \Ivory\GoogleMap\Exception\OverlayException If the radius is not valid.
     */
    public function setRadius($radius)
    {
        if (!is_numeric($radius)) {
            throw OverlayException::invalidCircleRadius();
        }

        $this->radius = $radius;
    }
}


<?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) Eric GELOEN <geloen.eric@gmail.com>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Base;

use Ivory\GoogleMap\Assets\AbstractJavascriptVariableAsset;
use Ivory\GoogleMap\Exception\BaseException;

/**
 * Coordinate which describes a google map coordinate.
 *
 * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLng
 * @author GeLo <geloen.eric@gmail.com>
 */
class Coordinate extends AbstractJavascriptVariableAsset
{
    /** @var double */
    protected $latitude;

    /** @var double */
    protected $longitude;

    /** @var boolean */
    protected $noWrap;

    /**
     * Create a coordinate
     *
     * @param double  $latitude  The latitude.
     * @param double  $longitude The longitude.
     * @param boolean $noWrap    The no wrap flag.
     */
    public function __construct($latitude = 0, $longitude = 0, $noWrap = true)
    {
        $this->setPrefixJavascriptVariable('coordinate_');

        $this->setLatitude($latitude);
        $this->setLongitude($longitude);
        $this->setNoWrap($noWrap);
    }

    /**
     * Gets the latitude.
     *
     * @return double The latitude.
     */
    public function getLatitude()
    {
        return $this->latitude;
    }

    /**
     * Sets the latitude
     *
     * @param double $latitude The latitude.
     *
     * @throws \Ivory\GoogleMap\Exception\BaseException If the latitude is not valid.
     */
    public function setLatitude($latitude)
    {
        if (!is_numeric($latitude) && ($latitude !== null)) {
            throw BaseException::invalidCoordinateLatitude();
        }

        $this->latitude = $latitude;
    }

    /**
     * Gets the longitude
     *
     * @return doube The longitude.
     */
    public function getLongitude()
    {
        return $this->longitude;
    }

    /**
     * Sets the longitude.
     *
     * @param double $longitude The longitude.
     *
     * @throws \Ivory\GoogleMap\Exception\BaseException If the longitude is not valid.
     */
    public function setLongitude($longitude)
    {
        if (!is_numeric($longitude) && ($longitude !== null)) {
            throw BaseException::invalidCoordinateLongitude();
        }

        $this->longitude = $longitude;
    }

    /**
     * Check if the coordinate is not wrap.
     *
     * @return boolean TRUE if the coordinate is not wrap else FALSE.
     */
    public function isNoWrap()
    {
        return $this->noWrap;
    }

    /**
     * Sets if the coordinate is wrap.
     *
     * @param boolean $noWrap TRUE if the coordinate is not wrap else FALSE.
     *
     * @throws \Ivory\GoogleMap\Exception\BaseException If the no wrap flag is not valid.
     */
    public function setNoWrap($noWrap)
    {
        if (!is_bool($noWrap) && ($noWrap !== null)) {
            throw BaseException::invalidCoordinateNoWrap();
        }

        $this->noWrap = $noWrap;
    }
}


<?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) Eric GELOEN <geloen.eric@gmail.com>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Controls;

use Ivory\GoogleMap\Exception\ControlException;

/**
 * Scale control options describes a google map scale control options
 *
 * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#ScaleControlOptions
 * @author GeLo <geloen.eric@gmail.com>
 */
class ScaleControl
{
    /** @var string */
    protected $controlPosition;

    /** @var string */
    protected $scaleControlStyle;

    /**
     * Creates a scale control.
     *
     * @param string $controlPosition   The control position.
     * @param string $scaleControlStyle The scale control style.
     */
    public function __construct(
        $controlPosition = ControlPosition::BOTTOM_LEFT,
        $scaleControlStyle = ScaleControlStyle::DEFAULT_
    ) {
        $this->setControlPosition($controlPosition);
        $this->setScaleControlStyle($scaleControlStyle);
    }

    /**
     * Gets the control position.
     *
     * @return string The control position.
     */
    public function getControlPosition()
    {
        return $this->controlPosition;
    }

    /**
     * Sets the control position.
     *
     * @param string $controlPosition The control position.
     *
     * @throws \Ivory\GoogleMap\Exception\ControlException If the control position is not valid.
     */
    public function setControlPosition($controlPosition)
    {
        if (!in_array($controlPosition, ControlPosition::getControlPositions())) {
            throw ControlException::invalidControlPosition();
        }

        $this->controlPosition = $controlPosition;
    }

    /**
     * Gets the scale control style.
     *
     * @return string The scale control style.
     */
    public function getScaleControlStyle()
    {
        return $this->scaleControlStyle;
    }

    /**
     * Sets the scale control style.
     *
     * @param type $scaleControlStyle The scale control style.
     *
     * @throws \Ivory\GoogleMap\Exception\ControlException If the scale control style is not valid.
     */
    public function setScaleControlStyle($scaleControlStyle)
    {
        if (!in_array($scaleControlStyle, ScaleControlStyle::getScaleControlStyles())) {
            throw ControlException::invalidScaleControlStyle();
        }

        $this->scaleControlStyle = $scaleControlStyle;
    }
}


<?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) Eric GELOEN <geloen.eric@gmail.com>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Services\Geocoding\Result;

/**
 * Geocoder status which describes a google map geocoder status.
 *
 * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderStatus
 * @author GeLo <geloen.eric@gmail.com>
 */
class GeocoderStatus
{
    const ERROR = 'ERROR';
    const INVALID_REQUEST = 'INVALID_REQUEST';
    const OK = 'OK';
    const OVER_QUERY_LIMIT = 'OVER_QUERY_LIMIT';
    const REQUEST_DENIED = 'REQUEST_DENIED';
    const UNKNOWN_ERROR = 'UNKNOWN_ERROR';
    const ZERO_RESULTS = 'ZERO_RESULTS';

    /**
     * Disabled constructor.
     *
     * @codeCoverageIgnore
     */
    final private function __construct()
    {

    }

    /**
     * Gets the available geocoder status.
     *
     * @return array The available geocoder status.
     */
    public static function getGeocoderStatus()
    {
        return array(
            self::ERROR,
            self::INVALID_REQUEST,
            self::OK,
            self::OVER_QUERY_LIMIT,
            self::REQUEST_DENIED,
            self::UNKNOWN_ERROR,
            self::ZERO_RESULTS,
        );
    }
}


<?php
/**
 * Dir cache utils.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare(strict_types=1);
namespace WebSharks\Core\Classes\Core\Utils;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * Dir cache utils.
 *
 * @since 170824.30708 Dir cache utils.
 */
class DirCache extends Classes\Core\Base\Core
{
    /**
     * Directory.
     *
     * @since 170824.30708
     *
     * @type string
     */
    protected $dir;

    /**
     * Directory.
     *
     * @since 170824.30708
     *
     * @type string
     */
    protected $tmp_dir;

    /**
     * Class constructor.
     *
     * @since 170824.30708 Dir cache utils.
     *
     * @param Classes\App $App Instance of App.
     */
    public function __construct(Classes\App $App)
    {
        parent::__construct($App);

        if (!$this->App->Config->©fs_paths['©cache_dir']) {
            throw $this->c::issue('Missing cache directory.');
        }
        $this->dir     = $this->App->Config->©fs_paths['©cache_dir'];
        $this->tmp_dir = $this->c::tmpDir(); // App-specific.
    }

    /**
     * Get a cached value.
     *
     * @since 170824.30708 Dir cache utils.
     *
     * @param string     $primary_key Primary key.
     * @param string|int $sub_key     Sub-key to get.
     * @param int        $max_age     Max age (in seconds).
     * @param array      $args        Any behavioral args.
     *
     * @return mixed|null Null if missing or expired.
     */
    public function get(string $primary_key, $sub_key, int $max_age = 0, array $args = [])
    {
        if (!isset($primary_key, $sub_key)) {
            return null; // Not possible.
        }
        $file = $this->dir; // App-specific.
        $file .= '/'.$this->subPath($primary_key, $sub_key, $args);

        if (!is_file($file)) {
            return null; // Cache miss.
        } elseif ($max_age && time() - filemtime($file) > $max_age) {
            return null; // Cache miss, too old.
        } elseif (($cache = file_get_contents($file)) === false) {
            return null; // Cache miss, read failure.
        } elseif (($cache = unserialize($cache)) === false) {
            return null; // Cache miss, unserialize failure.
        }
        if (isset($cache['x___value'], $cache['x___expires'])) {
            if ($cache['x___expires'] && $cache['x___expires'] <= time()) {
                return null; // Cache miss, value has expired.
            } else {
                return $cache['x___value']; // Cache hit!
            }
        } else { // e.g., Perhaps stored by an older version.
            return null; // Cache miss, unexpected data.
        }
    }

    /**
     * Cache a value.
     *
     * @since 170824.30708 Dir cache utils.
     *
     * @param string     $primary_key   Primary key.
     * @param string|int $sub_key       Sub-key to set.
     * @param mixed      $value         The value to cache.
     * @param int        $expires_after Expires after (in seconds).
     * @param array      $args          Any behavioral args.
     *
     * @NOTE Not possible to cache a `null` value because
     * {@link get()} returns `null` to indicate a cache miss.
     */
    public function set(string $primary_key, $sub_key, $value, int $expires_after = 0, array $args = [])
    {
        if (!isset($primary_key, $sub_key, $value)) {
            return; // Not possible.
        }
        $file = $this->dir; // App-specific.
        $file .= '/'.$this->subPath($primary_key, $sub_key, $args);
        $tmp_file = $this->tmp_dir.'/'.$this->c::uniqueId();

        $dir             = dirname($file); // May need to create this.
        $tmp_dir         = dirname($tmp_file); // May need to create this.
        $dir_permissions = $this->App->Config->©fs_permissions['©transient_dirs'];

        if ($expires_after > 0) {
            $expires = time() + $expires_after;
        } else {
            $expires = 0; // i.e., no expiration time.
        }
        $cache = serialize([
            'x___value'   => $value,
            'x___expires' => $expires,
        ]);
        if (!is_dir($dir)) {
            mkdir($dir, $dir_permissions, true);
        }
        if (!is_dir($tmp_dir)) {
            mkdir($tmp_dir, $dir_permissions, true);
        }
        if (file_put_contents($tmp_file, $cache) === false) {
            @unlink($tmp_file); // Cleanup on error.
            throw $this->c::issue(vars(), 'Cache `$tmp_file` write failure.');
            //
        } elseif (!rename($tmp_file, $file)) {
            @unlink($tmp_file); // Cleanup on error.
            throw $this->c::issue(vars(), 'Cache `$file` rename failure.');
        }
    }

    /**
     * Clear cache value(s).
     *
     * @since 170824.30708 Dir cache utils.
     *
     * @param string          $primary_key Primary key.
     * @param string|int|null $sub_key     Sub-key (optional).
     * @param array           $args        Any behavioral args.
     *
     * @return bool True on success.
     */
    public function clear(string $primary_key, $sub_key = null, array $args = []): bool
    {
        if (!isset($sub_key)) {
            $dir = $this->dir; // App-specific.
            $dir .= '/'.$this->subPath($primary_key, null, $args);
            return $this->c::deleteDir($dir, true);
        } else {
            $file = $this->dir; // App-specific.
            $file .= '/'.$this->subPath($primary_key, $sub_key, $args);
            return @unlink($file);
        }
    }

    /**
     * Key sub-path.
     *
     * @since 170824.30708 Dir cache utils.
     *
     * @param string          $primary_key Primary key.
     * @param string|int|null $sub_key     Sub-key to get.
     * @param array           $args        Any behavioral args.
     *
     * @return string Key sub-path.
     */
    protected function subPath(string $primary_key, $sub_key = null, array $args = []): string
    {
        if (!isset($sub_key)) {
            if (empty($args['preserve_keys'])) {
                extract($this->sha1Keys($primary_key, null, $args));
            }
            return $sub_path = $primary_key;
        } else {
            if (empty($args['preserve_keys'])) {
                extract($this->sha1Keys($primary_key, $sub_key, $args));
            }
            $shard_id        = $this->c::sha1ModShardId($primary_key.$sub_key);
            return $sub_path = $primary_key.'/'.$shard_id.'/'.$sub_key;
        }
    }

    /**
     * SHA-1 cache keys.
     *
     * @since 170824.30708 Dir cache utils.
     *
     * @param string          $primary_key Primary key.
     * @param string|int|null $sub_key     Sub-key to get.
     * @param array           $args        Any behavioral args.
     *
     * @return array `[primary_key]` or `[primary_key, sub_key]`.
     */
    protected function sha1Keys(string $primary_key, $sub_key = null, array $args = []): array
    {
        if (!$primary_key || !$this->c::isSha1($primary_key)) {
            $primary_key = sha1($primary_key);
        }
        if (!isset($sub_key)) {
            return compact('primary_key');
        } else {
            if (!$sub_key || !$this->c::isSha1($sub_key)) {
                $sub_key = sha1((string) $sub_key);
            }
            return compact('primary_key', 'sub_key');
        }
    }
}


<?php
/**
 * Dependency injector.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare(strict_types=1);
namespace WebSharks\Core\Classes\Core\Base;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;
#
use WebSharks\Dicer\Di as Dicer;

/**
 * Dependency injector.
 *
 * @since 150424 Initial release.
 */
class Di extends Dicer
{
    /**
     * App.
     *
     * @since 150424
     *
     * @type Classes\App
     */
    protected $App;

    /**
     * Class constructor.
     *
     * @since 150424 Initial release.
     *
     * @param Classes\App $App                 Instance of App.
     * @param array       $global_default_rule Default rule.
     */
    public function __construct(Classes\App $App, array $global_default_rule = [])
    {
        parent::__construct($global_default_rule);

        $this->App = $App;
    }

    /**
     * Get a class instance.
     *
     * @since 160224 Initial release.
     *
     * @param string $class_name Class path.
     * @param array  $args       Constructor args.
     * @param bool   $as_is      Class name as-is?
     *
     * @return object An object class instance.
     */
    public function get(string $class_name, array $args = [], bool $as_is = false)
    {
        return parent::get($as_is ? $class_name : $this->App->getClass($class_name), $args);
    }
}


<?php
/**
 * Tokenizer.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare (strict_types = 1);
namespace WebSharks\Core\Traits\Facades;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * Tokenizer.
 *
 * @since 151214
 */
trait Tokenizer
{
    /**
     * @since 151214 First facades.
     *
     * @param string $string   to underlying utility.
     * @param array  $tokenize to underlying utility.
     * @param array  $args     to underlying utility.
     *
     * @see Classes\Core\Tokenizer::__construct()
     */
    public static function tokenize(string $string, array $tokenize, array $args = []): Classes\Core\Tokenizer
    {
        return $GLOBALS[static::class]->Di->get(Classes\Core\Tokenizer::class, ['string' => $string, 'tokenize' => $tokenize, 'args' => $args]);
    }
}


<?php
/**
 * Regex patterns.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare (strict_types = 1);
namespace WebSharks\Core\Classes\Core\Utils;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * Regex patterns.
 *
 * @since 150424 Initial release.
 */
class RegexPatterns extends Classes\Core\Base\Core
{
    /**
     * Search values containing regex patterns against a string.
     *
     * @since 150424 Initial release.
     *
     * @param string $string            String to search within.
     * @param mixed  $value             Any value can be converted into a regex pattern.
     *                                  Actually, objects can't, but this recurses into objects.
     * @param bool   $collect_key_props Collect array keys and/or object properties?
     *
     * @return bool|array Will return `TRUE` if any regex pattern finds a match.
     *                    If `$collect_key_props` is `TRUE`, this will return an array.
     */
    public function match(string $string, $value, bool $collect_key_props = false)
    {
        if (!isset($string[0])) { // Empty?
            return $collect_key_props ? [] : false;
        }
        $matching_key_props = []; // Initialize.

        if (is_array($value) || is_object($value)) {
            foreach ($value as $_key_prop => $_value) {
                if (is_array($_value) || is_object($_value)) {
                    if (($_matching_key_props = $this->match($string, $_value, $collect_key_props))) {
                        if ($collect_key_props) {
                            $matching_key_props[] = [$_key_prop => $_matching_key_props];
                        } else {
                            return true;
                        }
                    }
                } elseif (is_string($_value) && isset($_value[0])) {
                    if (@preg_match($_value, $string)) {
                        if ($collect_key_props) {
                            $matching_key_props[] = $_key_prop;
                        } else {
                            return true;
                        }
                    }
                }
            } // unset($_key_prop, $_value, $_matching_key_props);
        } elseif (!$collect_key_props && is_string($value) && isset($value[0])) {
            if (@preg_match($value, $string)) {
                return true;
            }
        }
        return $collect_key_props ? $matching_key_props : false;
    }
}


<?php
namespace Perry\Representation\Eve\v1;

use \Perry\Representation\Reference as Reference;
use \Perry\Representation\Uri as Uri;
use \Perry\Representation\Base as Base;

class ItemCategory extends Base
{
    public $name;

    public $groups = [];

    public $published;

    // by Warringer\Types\String
    public function setName($name)
    {
        $this->name = $name;
    }

    // by Warringer\Types\ArrayType
    public function setGroups($groups)
    {
        // by Warringer\Types\Reference
        $func = function ($value) { return new Reference($value); };

        foreach ($groups as $key => $value) {
            $this->groups[$key] = $func($value);
        }
    }

    // by Warringer\Types\Base
    public function setPublished($published)
    {
        $this->published = $published;
    }

}


<?php
/**
 * Template utilities.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare(strict_types=1);
namespace WebSharks\Core\Classes\Core\Utils;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * Template utilities.
 *
 * @since 151121 Template utilities.
 */
class Template extends Classes\Core\Base\Core
{
    /**
     * Locates a template file.
     *
     * @since 160118 Template locater.
     *
     * @param string $file Relative to templates dir.
     * @param string $dir  From a specific directory?
     *
     * @return array Template `dir`, `file`, and `ext`.
     */
    public function locate(string $file, string $dir = ''): array
    {
        $is_file = false; // Initialize.
        $file    = $this->c::mbTrim($file, '/');
        $dir     = $this->c::mbRTrim($dir, '/');
        $dir     = $dir ?: $this->App->Config->©fs_paths['©templates_dir'];

        if ($dir === 'core') {
            if ($this->App->Parent) {
                return $this->App->Parent->Utils->©Template->locate($file, $dir);
            } else { // Use core config option.
                $dir = $this->App->Config->©fs_paths['©templates_dir'];
            }
        } elseif ($dir === 'parent' || ($dir && $file && !($is_file = is_file($dir.'/'.$file)))) {
            if ($this->App->Parent) {
                return $this->App->Parent->Utils->©Template->locate($file);
            } else { // Else go with what we have.
                $dir = $this->App->Config->©fs_paths['©templates_dir'];
            }
        }
        if ($dir && $file && !$is_file && !($is_file = is_file($dir.'/'.$file))) {
            $dir = dirname(__FILE__, 4).'/templates'; // WS core templates.
        }
        if ($dir && $file && ($is_file || ($is_file = is_file($dir.'/'.$file)))) {
            if (preg_match('/\/\.|\.\/|\.\./u', $this->c::normalizeDirPath($dir.'/'.$file))) {
                throw $this->c::issue(sprintf('Insecure template path: `%1$s`.', $dir.'/'.$file));
            }
            return ['dir' => $dir, 'file' => $file, 'ext' => $this->c::fileExt($file)];
        }
        return []; // Unable to locate.
    }

    /**
     * Gets template.
     *
     * @since 151121 Template utilities.
     *
     * @param string $file Relative to templates dir.
     * @param string $dir  From a specific directory?
     * @param array  $args Additional template args.
     *
     * @return Classes\Core\Template Template instance.
     */
    public function get(string $file, string $dir = '', array $args = []): Classes\Core\Template
    {
        return $this->App->Di->get(Classes\Core\Template::class, compact('dir', 'file', 'args'));
    }
}


<?php
//------------------------
//· 路由类
//---------------------
namespace denha;

class Route
{
    public static $path;
    public static $class;
    public static $uri;
    public static $rule   = [];
    public static $config = []; // 配置信息
    // 当前路由信息
    public static $thisRule = [
        'uri'  => '', // 原生地址
        'rule' => [], // 改写路由信息
    ];
    public static $id         = 0;
    public static $regularUrl = [];

    //执行主体
    public static function main($route = 'mca')
    {
        self::$config          = config('route');
        self::$thisRule['uri'] = self::$uri = self::parseUri();

        // 检查规则路由
        if (self::$config['open_route']) {

            include_once CONFIG_PATH . 'route.php';

            self::$uri = self::getRouteUrl('/' . self::$uri);
        }

        //转换Url参数为GET参数
        $uriArr = explode('/s/', self::$uri);
        if (isset($uriArr[1])) {
            self::changeGetValue($uriArr[1], ['isGet' => true]);
        }

        $routeArr = explode('/', ltrim(reset($uriArr), '/'));

        // 开启指定结构层数
        if (self::$config['open_level']) {
            $routeArr = array_values(array_slice($baseUriArr, 0, self::$config['level']));
        }

        define('MODULE', implode('.', array_slice($routeArr, 0, -2)));
        define('CONTROLLER', parsename(implode(array_slice($routeArr, -2, 1)), true));
        define('ACTION', end($routeArr));

        $class = ['app', str_replace('.', '\\', MODULE), CONTROLLER];

        return self::$class = implode('\\', $class);

    }

    /**
     * 保存路由规则
     * @date   2018-07-13T09:32:01+0800
     * @author ChenMingjiang
     * @param  [type]                   $url       [description]
     * @param  string                   $changeUrl [description]
     * @param  array                    $options   [description]
     * @return [type]                              [description]
     */
    public static function rule($url, $changeUrl = '/', $options = [])
    {

        $params      = isset($options['params']) ? $options['params'] : '';
        $suffix      = isset($options['suffix']) ? $options['suffix'] : '/';
        $limitSuffix = isset($options['limit_suffix']) ? explode(',', $options['limit_suffix']) : '';
        $jump        = isset($options['jump']) ? $options['jump'] : false;

        $key = md5($changeUrl . $params);

        self::$rule[self::$id] = [
            'url'          => $url,
            'change_url'   => $changeUrl,
            'params'       => $params,
            'suffix'       => $suffix,
            'limit_suffix' => $limitSuffix,
            'jump'         => $jump,
        ];

        self::$regularUrl['url'][md5($url . $params)]             = self::$id;
        self::$regularUrl['changeUrl'][md5($changeUrl . $params)] = self::$id;

        self::$id++;
    }

    // 解析请求URL
    public static function parseRouteUri($uri)
    {
        $uriArr = explode('/s/', $uri);

        if (isset($uriArr[1])) {
            $params    = $uriArr[1];
            $changeUrl = $uriArr[0];
        } else {
            $params    = '';
            $changeUrl = $uri;
        }

        $changeUrl = '/' . ltrim(trim($changeUrl), '/');

        return [$changeUrl, $params];
    }

    /** 获取实际路径 */
    public static function getRouteUrl($uri)
    {

        list($changeUrl, $params) = self::parseRouteUri($uri);

        // 获取后缀
        $suffix = pathinfo($changeUrl, PATHINFO_EXTENSION);
        if ($suffix) {
            // 删除后缀
            $changeUrl = str_replace('.' . $suffix, '', $changeUrl);
        }

        $isJump = false; //是否自动跳转

        // 原始地址+参数匹配 完全匹配
        $keyMD5 = md5($changeUrl . $params);
        if (isset(self::$regularUrl['changeUrl'][$keyMD5])) {
            $rule   = &self::$rule[self::$regularUrl['changeUrl'][$keyMD5]];
            $url    = $rule['url'];
            $isJump = $rule['jump'];

            self::$thisRule['rule'] = $rule; // 保存改写路由信息
            self::changeGetValue($rule['params']); // 保存GET参数
        }

        // 若完全匹配不存在 则不匹配参数只匹配路径  部分匹配
        if (!self::$thisRule['rule']) {
            $keyMD5 = md5($changeUrl);
            if (isset(self::$regularUrl['changeUrl'][$keyMD5])) {
                $rule   = &self::$rule[self::$regularUrl['changeUrl'][$keyMD5]];
                $url    = $rule['url'] . ($params ? '/s/' . $params : '');
                $isJump = $rule['jump'];

                self::$thisRule['rule'] = $rule; // 保存改写路由信息
                self::changeGetValue($rule['params']); // 保存GET参数

            }
        }

        //自动跳转Url
        if ($isJump) {
            die(header('Location:' . $url));
        }

        return isset($url) ? $url : $uri;
    }

    // 获取改写路径
    public static function getRouteChangeUrl($uri, $params = '')
    {

        list($changeUrl, $params) = self::parseRouteUri($uri);

        // 原始地址+参数匹配 完全匹配
        $keyMD5 = md5($changeUrl . $params);
        if (isset(self::$regularUrl['url'][$keyMD5])) {
            $rule = &self::$rule[self::$regularUrl['url'][$keyMD5]];
            self::changeGetValue($rule['params']); // 保存GET信息
            if ($rule['change_url']) {
                $url = $rule['change_url'] . $rule['suffix'];
            } else {
                $url = $rule['change_url'];
            }

        }

        // 若完全匹配不存在 则不匹配参数只匹配路径  部分匹配
        if (!isset($url)) {
            $keyMD5 = md5($changeUrl);
            if (isset(self::$regularUrl['url'][$keyMD5])) {
                $rule = &self::$rule[self::$regularUrl['url'][$keyMD5]];
                // 增加自带参数 过来 多"/"情况
                $url = '/' . ltrim(($rule['change_url'] . ($params ? '/s/' . $params : '') . $rule['suffix']), '/');

            }
        }

        return isset($url) ? $url : $uri;
    }

    // 获取当前路由信息
    public static function getRule()
    {
        return self::$thisRule;
    }

    //获取直接参数
    private static function initValue($flag, $value)
    {
        $res = (isset($_GET[$flag]) && $_GET[$flag] ? strip_tags($_GET[$flag]) : $value);
        return $res;
    }

    //解析路由
    private static function parseUri()
    {
        //去除urldecode转码 转码会导致get参数 带/解析错误
        // $uri = urldecode($_SERVER['REQUEST_URI']);
        $uri = $_SERVER['REQUEST_URI'];
        if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) {
            $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
        }

        // 删除"/"
        $uri = trim($uri, '/');
        if (!$uri) {
            return false;
        }

        // 删除参数
        $pos = strpos($uri, '?');
        if ($pos !== false) {
            $uri = substr($uri, 0, $pos);
        }

        if ($uri) {
            return $uri;
        } else {
            return false;
        }
    }

    /**
     * 转换GET参数
     * GET原始模式的参数优先级最高
     * @date   2019-02-27T11:16:12+0800
     * @author ChenMingjiang
     * @param  [type]                   $uri     [description]
     * @param  array                    $options [description]
     *                                           isGet:是否保存GET值 默认不保存
     * @return [type]                   [description]
     */
    public static function changeGetValue($uri, $options = [])
    {

        $isGet = isset($options['isGet']) ? isset($options['isGet']) : false;

        if (!$uri) {
            return false;
        }

        //转换参数

        $paramItems = array_values(explode('/', $uri));

        $total = count($paramItems);

        $result = [];

        for ($i = 0; $i < $total;) {
            if (isset($paramItems[$i + 1])) {
                // 匹配数组
                $regular = '/(.*?)\[(.*?)\]/';
                preg_match($regular, $paramItems[$i], $matches);

                if ($matches) {

                    $result[$matches[1]][$matches[2]] = urldecode($paramItems[$i + 1]);

                    if ($isGet) {
                        // 保存数组信息 如果不存在 $_GET 信息
                        if (!isset($_GET[$matches[1]][$matches[2]])) {
                            $_GET[$matches[1]][$matches[2]] = urldecode($paramItems[$i + 1]);
                        }

                        $result[$matches[1]][$matches[2]] = $_GET[$matches[1]][$matches[2]];
                    }

                } else {
                    $result[$paramItems[$i]] = urldecode($paramItems[$i + 1]);
                    if ($isGet) {
                        // 保存数组信息 如果不存在 $_GET 信息
                        if (!isset($_GET[$paramItems[$i]])) {
                            $_GET[$paramItems[$i]] = urldecode($paramItems[$i + 1]);
                        }

                        $result[$paramItems[$i]] = $_GET[$paramItems[$i]];
                    }

                }
            }
            $i += 2;
        }

        return $result;

    }

}


<?php
namespace Perry\Representation\Eve\v2;

use \Perry\Representation\Reference as Reference;
use \Perry\Representation\Uri as Uri;
use \Perry\Representation\Base as Base;

class ItemType extends Base
{
    public $name;

    public $icon64;

    public $extraAttributes;

    public $mShortDescription;

    public $icon32;

    public $attributes;

    public $description;

    // by Warringer\Types\String
    public function setName($name)
    {
        $this->name = $name;
    }

    // by Warringer\Types\Reference
    public function setIcon64($icon64)
    {
        $this->icon64 = new Reference($icon64);
    }

    // by Warringer\Types\Dict
    public function setExtraAttributes($extraAttributes)
    {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['skeletalMeshMale'] = function ($value) { return $value; };
        $converters['modifier'] = function ($values) {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['modifierValue'] = function ($value) { return $value; };
        $converters['attributeName'] = function ($value) { return $value; };
        $converters['modifierType'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['modifierValue'] = isset($value->{'modifierValue'}) ? $converters['modifierValue']($value->{'modifierValue'}) : null;
            $return['attributeName'] = isset($value->{'attributeName'}) ? $converters['attributeName']($value->{'attributeName'}) : null;
            $return['modifierType'] = isset($value->{'modifierType'}) ? $converters['modifierType']($value->{'modifierType'}) : null;
            return $return;
        };

            foreach ($values as $key => $value) {
                 $values[$key] = $func($value);
            }
           return $values;
        };

        $converters['slotType'] = function ($value) { return $value; };
        $converters['skeletalMeshFemale'] = function ($value) { return $value; };
        $converters['mVICProp'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['skeletalMeshMale'] = isset($value->{'skeletalMeshMale'}) ? $converters['skeletalMeshMale']($value->{'skeletalMeshMale'}) : null;
            $return['modifier'] = isset($value->{'modifier'}) ? $converters['modifier']($value->{'modifier'}) : null;
            $return['slotType'] = isset($value->{'slotType'}) ? $converters['slotType']($value->{'slotType'}) : null;
            $return['skeletalMeshFemale'] = isset($value->{'skeletalMeshFemale'}) ? $converters['skeletalMeshFemale']($value->{'skeletalMeshFemale'}) : null;
            $return['mVICProp'] = isset($value->{'mVICProp'}) ? $converters['mVICProp']($value->{'mVICProp'}) : null;
            return $return;
        };
        $this->extraAttributes = $func($extraAttributes);
    }

    // by Warringer\Types\String
    public function setMShortDescription($mShortDescription)
    {
        $this->mShortDescription = $mShortDescription;
    }

    // by Warringer\Types\Reference
    public function setIcon32($icon32)
    {
        $this->icon32 = new Reference($icon32);
    }

    // by Warringer\Types\Dict
    public function setAttributes($attributes)
    {
        // by Warringer\Types\Dict
        $converters = [];
        $converters['cpu'] = function ($value) { return $value; };
        $converters['power'] = function ($value) { return $value; };
        $converters['heatDamage'] = function ($value) { return $value; };

        $func = function ($value) use($converters) {
            $return = new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS);
            $return['cpu'] = isset($value->{'cpu'}) ? $converters['cpu']($value->{'cpu'}) : null;
            $return['power'] = isset($value->{'power'}) ? $converters['power']($value->{'power'}) : null;
            $return['heatDamage'] = isset($value->{'heatDamage'}) ? $converters['heatDamage']($value->{'heatDamage'}) : null;
            return $return;
        };
        $this->attributes = $func($attributes);
    }

    // by Warringer\Types\String
    public function setDescription($description)
    {
        $this->description = $description;
    }

}


<?php
/**
 * Password utilities.
 *
 * @author @jaswrks
 * @copyright WebSharks™
 */
declare(strict_types=1);
namespace WebSharks\Core\Classes\Core\Utils;

use WebSharks\Core\Classes;
use WebSharks\Core\Interfaces;
use WebSharks\Core\Traits;
#
use WebSharks\Core\Classes\Core\Error;
use WebSharks\Core\Classes\Core\Base\Exception;
#
use function assert as debug;
use function get_defined_vars as vars;

/**
 * Password utilities.
 *
 * @since 150424 Initial release.
 */
class Password extends Classes\Core\Base\Core
{
    /**
     * Password strength.
     *
     * @since 17xxxx Password strength.
     *
     * @param string $password Password.
     *
     * @return int Strength (0 - 100).
     */
    public function strength(string $password): int
    {
        $score = 0; // Initialize.

        if (!isset($password[0])) {
            return $score;
        }
        if (preg_match('/\p{N}/u', $password)) {
            $score += 25; // Number.
        }
        if (preg_match('/\p{Ll}/u', $password)) {
            $score += 25; // Lowercase.
        }
        if (preg_match('/\p{Lu}/u', $password)) {
            $score += 25; // Uppercase.
        }
        if (preg_match('/[^\p{N}\p{Ll}\p{Lu}]/u', $password)) {
            $score += 25; // Special symbol.
        }
        return $score;
    }

    /**
     * Generates a password hash.
     *
     * @since 150424 Initial release.
     *
     * @param string $string String to sign.
     * @param string $key    Encryption key.
     *
     * @return string Hash (a keyed SHA-256 signature; 64 chars).
     */
    public function sha256(string $string, string $key = ''): string
    {
        if (!$key && !($key = $this->App->Config->©passwords['©hash_key'])) {
            throw $this->c::issue('Missing password hash key.');
        }
        return $this->c::sha256KeyedHash($string, $key);
    }
}