<?php namespace Arcanesoft\Foundation\Http\Routes\Admin;

use Arcanedev\Support\Routing\RouteRegistrar;

/**
 * Class     SystemRoutes
 *
 * @package  Arcanesoft\Foundation\Http\Routes\Admin
 * @author   ARCANEDEV <arcanedev.maroc@gmail.com>
 */
class SystemRoutes extends RouteRegistrar
{
    /* -----------------------------------------------------------------
     |  Main Methods
     | -----------------------------------------------------------------
     */

    /**
     * Bind routes.
     */
    public static function bindings()
    {
        (new static)->bind('logviewer_log_date', function ($date) {
            return log_viewer()->get($date);
        });
    }

    /**
     * Map routes.
     */
    public function map()
    {
        $this->namespace('System')->prefix('system')->name('system.')->group(function () {
            $this->registerSystemInformationRoutes();
            $this->registerLogViewerRoutes();
            $this->registerRouteViewerRoutes();
        });
    }

    /* -----------------------------------------------------------------
     |  Other Methods
     | -----------------------------------------------------------------
     */

    /**
     * Register the system information routes.
     */
    private function registerSystemInformationRoutes()
    {
        $this->prefix('information')->name('information.')->group(function () {
            $this->get('/', 'InformationController@index')
                 ->name('index');  // admin::foundation.system.information.index
        });
    }

    /**
     * Register LogViewer routes.
     */
    private function registerLogViewerRoutes()
    {
        $this->prefix('log-viewer')->name('log-viewer.')->group(function () {
            $this->get('/', 'LogViewerController@index')
                 ->name('index'); // admin::foundation.system.log-viewer.index

            $this->prefix('logs')->name('logs.')->group(function() {
                $this->get('/', 'LogViewerController@listLogs')
                     ->name('list'); // admin::foundation.system.log-viewer.logs.list

                $this->prefix('{logviewer_log_date}')->group(function () {
                    $this->get('/', 'LogViewerController@show')
                         ->name('show'); // admin::foundation.system.log-viewer.logs.show

                    $this->get('download', 'LogViewerController@download')
                         ->name('download'); // admin::foundation.system.log-viewer.logs.download

                    $this->get('{level}', 'LogViewerController@showByLevel')
                         ->name('filter'); // admin::foundation.system.log-viewer.logs.filter

                    $this->get('{level}/search', 'LogViewerController@search')
                         ->name('search'); // admin::foundation.system.log-viewer.logs.search

                    $this->delete('delete', 'LogViewerController@delete')
                         ->middleware('ajax')
                         ->name('delete'); // admin::foundation.system.log-viewer.logs.delete
                });
            });
        });
    }

    /**
     * Register the route viewer routes.
     */
    private function registerRouteViewerRoutes()
    {
        $this->prefix('routes')->name('routes.')->group(function () {
            $this->get('/', 'RoutesController@index')
                 ->name('index'); // admin::foundation.system.routes.index
        });
    }
}


<?php

namespace Omnipay\Klarna\Message;

use Klarna;
use KlarnaCountry;
use KlarnaCurrency;
use KlarnaLanguage;
use KlarnaException;
use InvalidArgumentException;
use Subscribo\Omnipay\Shared\Message\AbstractRequest;
use Subscribo\Omnipay\Shared\ItemBag;

/**
 * Abstract Class AbstractInvoiceRequest
 *
 * @package Omnipay\Klarna
 */
abstract class AbstractInvoiceRequest extends AbstractRequest
{
    public function sendData($data)
    {
        $connector = $this->prepareConnector($data);

        try {
            $result = $this->sendRequestViaConnector($connector, $data);

            $this->response = $this->createResponse($result);

        } catch (KlarnaException $e) {
            $code = $e->getCode();
            if (($code < 0) or ($code > 1100)) {
                $this->response = $this->createResponse($e);
            } else {
                throw $e;
            }
        }

        return $this->response;
    }

    /**
     * @param Klarna $connector
     * @param array $data
     * @return array
     * @throws KlarnaException
     */
    abstract protected function sendRequestViaConnector(Klarna $connector, array $data);

    /**
     * @param array|KlarnaException $data
     * @return \Omnipay\Klarna\Message\AbstractInvoiceResponse
     */
    abstract protected function createResponse($data);

    /**
     * @param $data
     * @return Klarna
     */
    protected function prepareConnector($data)
    {
        return $this->createKlarnaConnector($data);
    }

    /**
     * Creates an instance of Klarna, an also check, whether provided data are an array (common functionality)
     *
     * @param array $data
     * @return Klarna
     * @throws \InvalidArgumentException
     */
    protected function createKlarnaConnector($data)
    {
        if (( ! is_array($data))) {
            throw new InvalidArgumentException('Data parameter should be an array');
        }
        $klarnaConnector = new Klarna();
        $country = KlarnaCountry::fromCode($data['country']);
        $language = KlarnaLanguage::fromCode($data['language']);
        $currency = KlarnaCurrency::fromCode($data['currency']);
        $mode = empty($data['testMode']) ? Klarna::LIVE : Klarna::BETA;
        $klarnaConnector->config(
            $data['merchantId'],
            $data['sharedSecret'],
            $country,
            $language,
            $currency,
            $mode
        );
        if (( ! empty($data['clientIp']))) {
            $klarnaConnector->setClientIP($data['clientIp']);
        }
        return $klarnaConnector;
    }

    /**
     * @param ItemBag|null $itemBag
     * @return array
     */
    protected function extractArticles(ItemBag $itemBag = null)
    {
        if (empty($itemBag)) {
            return [];
        }
        $articles = [];
        $items = $itemBag->all();
        /** @var \Subscribo\Omnipay\Shared\Item $item */
        foreach ($items as $item) {
            $article = [
                'quantity' => $item->getQuantity(),
                'artNo' => $item->getIdentifier(),
                'title' => $item->getName(),
                'price' => $item->getPrice(),
                'vat'   => $item->getTaxPercent() ?: 0,
                'discount' => $item->getDiscountPercent() ?: 0,
                'flags' => $item->getFlags(),
            ];
            $articles[] = $article;
        }
        return $articles;
    }
}


<?php

namespace Bavix\Router;

use Bavix\Exceptions;
use Bavix\Router\Rules\PatternRule;
use Psr\Cache\CacheItemPoolInterface;

class Router
{

    /**
     * Router version
     */
    public const VERSION = '2.0.0';

    /**
     * @var Group[]
     */
    protected $groups = [];

    /**
     * @var PatternRule[]
     */
    protected $routes;

    /**
     * @var array
     */
    protected $config = [];

    /**
     * @var CacheItemPoolInterface
     */
    protected $pool;

    /**
     * Router constructor.
     *
     * @param iterable $data
     * @param CacheItemPoolInterface $pool
     */
    public function __construct($data, CacheItemPoolInterface $pool = null)
    {
        $this->addPattern($data);
        $this->pool = $pool;
    }

    /**
     * @param \Traversable|iterable $config
     * @return Router
     */
    protected function addPattern($config): self
    {
        $this->routes = null;
        $this->config = \array_merge(
            $this->config,
            $this->asArray($config)
        );

        return $this;
    }

    /**
     * @param array|\Traversable $data
     *
     * @return array
     */
    protected function asArray($data): array
    {
        if (!\is_array($data)) {
            return \iterator_to_array($data);
        }

        return $data;
    }

    /**
     * @param string $prefix
     * @param callable $callback
     *
     * @return Group
     */
    public function group(string $prefix, callable $callback): Group
    {
        $group = new Group($prefix, $callback);
        $this->mount($group);
        return $group;
    }

    /**
     * @param Group $group
     * @return Router
     */
    public function mount(Group $group): self
    {
        $this->routes = null;
        $this->groups[] = $group;
        return $this;
    }

    /**
     * @param Pattern $pattern
     * @return Router
     */
    public function push(Pattern $pattern): self
    {
        return $this->addPattern($pattern->toArray());
    }

    /**
     * @return Route
     *
     * @throws Exceptions\NotFound\Data
     * @throws Exceptions\NotFound\Path
     * @throws Exceptions\NotFound\Page
     */
    public function getCurrentRoute(): Route
    {
        return $this->getRoute(Server::sharedInstance()->path());
    }

    /**
     * @param string $path
     * @param string $host
     * @param string $protocol
     *
     * @return Route
     *
     * @throws Exceptions\NotFound\Data
     * @throws Exceptions\NotFound\Path
     * @throws Exceptions\NotFound\Page
     */
    public function getRoute(string $path, string $host = null, string $protocol = null): Route
    {
        return $this->find(Server::url($path, $host, $protocol));
    }

    /**
     * @param string $subject
     * @return Route
     * @throws Exceptions\NotFound\Page
     */
    protected function find(string $subject): Route
    {
        foreach ($this->routes() as $name => $patternRule) {
            $match = new Match($patternRule, $subject, Server::sharedInstance()->method());
            if ($match->isTest()) {
                return new Route($match);
            }
        }

        throw new Exceptions\NotFound\Page('Page `' . $subject . '` not found', 404);
    }

    /**
     * @return Route[]
     */
    public function routes(): array
    {
        if (empty($this->routes)) {
            $this->routes = $this->bootRoutes();
        }

        return $this->routes;
    }

    /**
     * @return array
     * @throws
     */
    protected function bootRoutes(): array
    {
        if ($this->pool) {
            $item = $this->pool->getItem($this->hash());
            $data = $item->get();
            if ($data) {
                return $data;
            }
        }

        return $this->loadingRoutes();
    }

    /**
     * @return string
     */
    protected function hash(): string
    {
        $config = \json_encode($this->config);
        $groups = \json_encode($this->groups);
        return \crc32(self::VERSION . $config . $groups);
    }

    /**
     * @return array
     * @throws
     */
    protected function loadingRoutes(): array
    {
        $this->loadingGroups();
        $loader = new Loader($this->config);
        $this->routes = $loader->simplify();

        if ($this->pool) {
            $item = $this->pool->getItem($this->hash());
            $item->set($this->routes);
            $this->pool->save($item);
        }

        return $this->routes;
    }

    /**
     * loading mounted groups
     */
    protected function loadingGroups(): void
    {
        foreach ($this->groups as $group) {
            $this->addPattern($group->toArray());
        }
    }

    /**
     * @param string $path
     *
     * @return Route
     *
     * @throws Exceptions\NotFound\Path
     */
    public function route(string $path): Route
    {
        $routes = $this->routes();

        if (empty($routes[$path])) {
            throw new Exceptions\NotFound\Path('Route `' . $path . '` not found');
        }

        return $routes[$path];
    }

}


<?php

namespace Bavix\Router;

class Resolver implements GroupResolution
{

    /**
     * @var callable
     */
    protected $collections;

    /**
     * @var callable
     */
    protected $patterns;

    /**
     * Resolver constructor.
     *
     * @param callable $patterns
     * @param callable $collections
     */
    public function __construct(callable $patterns, callable $collections)
    {
        $this->collections = $collections;
        $this->patterns = $patterns;
    }

    /**
     * @param array $methods
     * @param string $path
     * @param null|string $name
     *
     * @return Pattern
     */
    public function methods(array $methods, string $path, ?string $name): Pattern
    {
        return $this->pushPattern($this->pattern($path, $name))->methods($methods);
    }

    /**
     * @param Pattern $pattern
     *
     * @return Pattern
     */
    protected function pushPattern(Pattern $pattern): Pattern
    {
        return \call_user_func($this->patterns, $pattern);
    }

    /**
     * @param string $path
     * @param null|string $name
     * @return Pattern
     */
    protected function pattern(string $path, ?string $name): Pattern
    {
        return new Pattern($path, $name);
    }

    /**
     * GET|POST|PUT|PATCH|HEAD|OPTIONS|DELETE
     *
     * @param string $path
     * @param null|string $name
     *
     * @return Pattern
     */
    public function any(string $path, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->pattern($path, $name))->any();
    }

    /**
     * @param string $path
     * @param null|string $name
     *
     * @return Pattern
     */
    public function get(string $path, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->pattern($path, $name))->get();
    }

    /**
     * @param string $path
     * @param null|string $name
     *
     * @return Pattern
     */
    public function post(string $path, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->pattern($path, $name))->post();
    }

    /**
     * @param string $path
     * @param null|string $name
     *
     * @return Pattern
     */
    public function put(string $path, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->pattern($path, $name))->put();
    }

    /**
     * @param string $path
     * @param null|string $name
     *
     * @return Pattern
     */
    public function patch(string $path, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->pattern($path, $name))->patch();
    }

    /**
     * @param string $path
     * @param null|string $name
     *
     * @return Pattern
     */
    public function delete(string $path, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->pattern($path, $name))->delete();
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @return Pattern
     */
    public function index(string $entityName, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->_index($entityName, $name));
    }

    /**
     * entityName -> /users
     *
     *  GET         users.index     /users
     *
     * @param string $entityName
     * @param null|string $name
     * @return Pattern
     */
    protected function _index(string $entityName, ?string $name = null): Pattern
    {
        return $this->pattern(
            $entityName,
            $this->name($name, 'index')
        )->get();
    }

    /**
     * @param string $name
     * @param string $index
     * @return string
     */
    protected function name(string $name, string $index): string
    {
        return $name . '.' . $index;
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @return Pattern
     */
    public function create(string $entityName, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->_create($entityName, $name));
    }

    /**
     * entityName -> /users
     *
     *  GET         users.create    /users/create
     *
     * @param string $entityName
     * @param null|string $name
     * @return Pattern
     */
    protected function _create(string $entityName, ?string $name = null): Pattern
    {
        return $this->pattern(
            $this->action($entityName, 'create'),
            $this->name($name, 'create')
        )->get();
    }

    /**
     * @param string $entityName
     * @param string $action
     * @return string
     */
    protected function action(string $entityName, string $action): string
    {
        return $entityName . '/' . $action;
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @return Pattern
     */
    public function store(string $entityName, ?string $name = null): Pattern
    {
        return $this->pushPattern($this->_store($entityName, $name));
    }

    /**
     * entityName -> /users
     *
     *  POST        users.store     /users
     *
     * @param string $entityName
     * @param null|string $name
     * @return Pattern
     */
    protected function _store(string $entityName, ?string $name = null): Pattern
    {
        return $this->pattern(
            $entityName,
            $this->name($name, 'store')
        )->post();
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    public function show(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pushPattern($this->_show($entityName, $name, $id));
    }

    /**
     * entityName -> /users
     *
     *  GET         users.show      /users/{id}
     *
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    protected function _show(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pattern(
            $this->id($entityName, $id),
            $this->name($name, 'show')
        )->get();
    }

    /**
     * @param string $entityName
     * @param string $id
     * @return string
     */
    protected function id(string $entityName, string $id): string
    {
        return $this->action($entityName, '<' . $id . '>');
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    public function edit(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pushPattern($this->_edit($entityName, $name, $id));
    }

    /**
     * entityName -> /users
     *
     *  GET         users.edit      /users/{id}/edit
     *
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    protected function _edit(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pattern(
            $this->idAction($entityName, $id, 'edit'),
            $this->name($name, 'edit')
        )->get();
    }

    /**
     * @param string $entityName
     * @param string $id
     * @param string $action
     * @return string
     */
    protected function idAction(string $entityName, string $id, string $action): string
    {
        return $this->action($this->id($entityName, $id), $action);
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    public function update(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pushPattern($this->_update($entityName, $name, $id));
    }

    /**
     * entityName -> /users
     *
     *  PUT/PATCH   users.update    /users/{id}/edit
     *
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    protected function _update(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pattern(
            $this->idAction($entityName, $id, 'edit'),
            $this->name($name, 'update')
        )->setMethods(['PUT', 'PATCH']);
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    public function destroy(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pushPattern($this->_destroy($entityName, $name, $id));
    }

    /**
     * entityName -> /users
     *
     *  DELETE      users.destroy   /users/{id}
     *
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     * @return Pattern
     */
    protected function _destroy(string $entityName, ?string $name = null, ?string $id = null): Pattern
    {
        return $this->pattern(
            $this->id($entityName, $id),
            $this->name($name, 'destroy')
        )->delete();
    }

    /**
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     *
     * @return ResourceCollection
     */
    public function apiResource(string $entityName, ?string $name = null, ?string $id = null): ResourceCollection
    {
        return $this->resource($entityName, $name, $id)->only([
            'index', 'store', 'show', 'update', 'destroy'
        ]);
    }

    /**
     * entityName -> /users
     *
     *  GET         users.index     /users
     *  GET         users.create    /users/create
     *  POST        users.store     /users
     *  GET         users.show      /users/{id}
     *  GET         users.edit      /users/{id}/edit
     *  PUT/PATCH   users.update    /users/{id}/edit
     *  DELETE      users.destroy   /users/{id}
     *
     * @param string $entityName
     * @param null|string $name
     * @param null|string $id
     *
     * @return ResourceCollection
     */
    public function resource(string $entityName, ?string $name = null, ?string $id = null): ResourceCollection
    {
        $entityName = \rtrim($entityName, '/');
        $name = $name ?: \ltrim($entityName, '/');
        $id = $id ?: $name;

        return $this->pushCollection(new ResourceCollection([
            'index' => $this->_index($entityName, $name),
            'create' => $this->_create($entityName, $name),
            'store' => $this->_store($entityName, $name),
            'show' => $this->_show($entityName, $name, $id),
            'edit' => $this->_edit($entityName, $name, $id),
            'update' => $this->_update($entityName, $name, $id),
            'destroy' => $this->_destroy($entityName, $name, $id)
        ]));
    }

    /**
     * @param ResourceCollection $collection
     *
     * @return ResourceCollection
     */
    protected function pushCollection(ResourceCollection $collection): ResourceCollection
    {
        return \call_user_func($this->collections, $collection);
    }

}


<?php

/*
 * This file is part of gpupo/search
 *
 * (c) Gilmar Pupo <contact@gpupo.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Gpupo\Search\Result;

use Gpupo\Common\Entity\CollectionAbstract;

abstract class ItemAbstract extends CollectionAbstract
{
    /**
     * Acesso aos atributos fornecidos pelo SphinxSearch.
     *
     * @return array
     */
    protected function getAtributos()
    {
        return $this->get('attrs');
    }

    /**
     * Acesso a um atributo específico.
     *
     * @param string $key
     */
    protected function getAtributo($key)
    {
        $attrs = $this->get('attrs');

        if (isset($attrs[$key])) {
            return $attrs[$key];
        }

        return;
    }

    protected function toLineString($chave)
    {
        $method = 'get'.ucfirst($chave);

        $string = ' - '.$chave.':'.$this->$method();
        $string .= "\n";

        return $string;
    }

    /**
     * @param string $key
     */
    public function find($key)
    {
        if ($attr = $this->getAtributo($key)) {
            return $attr;
        }

        return $this->get($key);
    }
}


<?php

/*
 * This file is part of gpupo/search
 *
 * (c) Gilmar Pupo <contact@gpupo.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Gpupo\Search\Paginator;

/**
 * Componente de paginacao de resultados da Busca.
 *
 * Não gerencia os itens de resultados, mas apenas os números de limite e offset
 * de uma query Sphinx Search
 *
 * Usado como referencia o Knp Pager component.
 */
abstract class PaginatorAbstract
{
    protected $range = 5;
    protected $currentPageNumber;
    protected $numItemsPerPage;
    protected $totalCount;

    public function setCurrentPageNumber($pageNumber)
    {
        $this->currentPageNumber = $pageNumber;
    }

    /**
     * Get currently used page number.
     *
     * @return int
     */
    public function getCurrentPageNumber()
    {
        return $this->currentPageNumber;
    }

    public function setItemNumberPerPage($numItemsPerPage)
    {
        $this->numItemsPerPage = $numItemsPerPage;
    }

    /**
     * Get number of items per page.
     *
     * @return int
     */
    public function getItemNumberPerPage()
    {
        return $this->numItemsPerPage;
    }

    public function setTotalItemCount($numTotal)
    {
        $this->totalCount = $numTotal;
    }

    /**
     * Get total item number available.
     *
     * @return int
     */
    public function getTotalItemCount()
    {
        return $this->totalCount;
    }

    /**
     * Offsets the result list by the number of places set by the count;.
     *
     * This would be used for pagination through results, where if you have 20
     * results per 'page', the second page would begin at offset 20, the third
     * page at offset 40, etc.
     *
     * @return int
     */
    public function getOffset()
    {
        return abs($this->getCurrentPageNumber() - 1) * $this->getItemNumberPerPage();
    }

    /**
     * Processa os valors de resultado.
     *
     * @param int $numTotal
     * @param int $page
     * @param int $limit
     */
    public function paginate($numTotal, $page, $limit = 10)
    {
        $this->setTotalItemCount($numTotal);
        $this->setCurrentPageNumber($page);
        $this->setItemNumberPerPage($limit);
    }

    public function getPagesCount()
    {
        return intval(ceil($this->getTotalItemCount() / $this->getItemNumberPerPage()));
    }

    /**
     * Pagination page range.
     *
     * @param int $range
     */
    public function setPageRange($range)
    {
        $this->range = intval(abs($range));
    }

    /**
     * Pagination page range.
     *
     * @return int
     */
    public function getPageRange()
    {
        return $this->range;
    }
}


<?php

namespace Bavix\Router;

use Bavix\Exceptions\Runtime;

class Path implements \Serializable, \JsonSerializable
{

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

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

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

    /**
     * @var array
     */
    protected $regex;

    /**
     * Path constructor.
     *
     * @param string $defaultRegex
     * @param string $value
     * @param array $regex
     */
    public function __construct(string $defaultRegex, string $value, array $regex = [])
    {
        $this->defaultRegex = $defaultRegex;
        $this->value = $value;
        $this->regex = $regex;
        $this->processing();
    }

    /**
     * processing:
     *  path: '/(<lang:\w+>)' -> '/(<lang>)'
     *  re: [] -> ['lang' => '\w+']
     *
     *  if attr exists -> throws
     */
    protected function processing(): void
    {
        $this->value = \preg_replace_callback(
            '~\<(?<key>' . $this->defaultRegex . '+):(?<value>.+?)>~',
            function (array $matches) {

                if (!empty($this->regex[$matches['key']])) {
                    throw new Runtime(\sprintf(
                        'duplicate in registry key `%s` for path `%s`',
                        $matches['key'],
                        $this->value
                    ));
                }

                if (!empty($matches['value'])) {
                    $this->regex[$matches['key']] = $matches['value'];
                }

                return '<' . $matches['key'] . '>';
            },
            $this->value
        );
    }

    /**
     * @return string
     */
    public function getPattern(): string
    {
        if (!$this->pattern) {
            $this->pattern = \preg_replace_callback(
                '~\<(?<key>' . $this->defaultRegex . '+)\>~',
                function ($matches) {
                    return '(?<' . $matches['key'] . '>' .
                        $this->regexAttribute($matches['key']) .
                        ')';
                },
                $this->quote($this->value)
            );
        }
        return $this->pattern;
    }

    /**
     * @param string $name
     *
     * @return string
     */
    protected function regexAttribute(string $name): string
    {
        return $this->regex[$name] ?? $this->defaultRegex;
    }

    /**
     * @param string $value
     *
     * @return string
     */
    protected function quote(string $value): string
    {
        $path = \preg_quote($value, '()');
        $path = \strtr($path, [
            '\\(' => '(',
            '\\)' => ')',
            '\\<' => '<',
            '\\>' => '>',
        ]);

        return \str_replace(')', ')?', $path);
    }

    /**
     * @return string
     */
    public function getValue(): string
    {
        return $this->value;
    }

    /**
     * @return array
     */
    public function getRegex(): array
    {
        return $this->regex;
    }

    /**
     * @param self $parent
     */
    public function hinge(self $parent): void
    {
        $this->pattern = null;
        $this->value = $parent->value . $this->value;
        $this->regex = \array_merge(
            $parent->regex,
            $this->regex
        );
    }

    /**
     * @return array
     */
    public function __sleep(): array
    {
        return \array_keys($this->jsonSerialize());
    }

    /**
     * @inheritdoc
     */
    public function jsonSerialize(): array
    {
        return [
            'defaultRegex' => $this->defaultRegex,
            'pattern' => $this->pattern,
            'regex' => $this->regex,
            'value' => $this->value,
        ];
    }

    /**
     * @inheritdoc
     */
    public function serialize(): string
    {
        return \serialize($this->jsonSerialize());
    }

    /**
     * @inheritdoc
     */
    public function unserialize($serialized): void
    {
        foreach (\unserialize($serialized, (array)null) as $key => $value) {
            $this->$key = $value;
        }
    }

}


<?php namespace Arcanesoft\Foundation\Console;

use Arcanesoft\Foundation\FoundationServiceProvider;

/**
 * Class     PublishCommand
 *
 * @package  Arcanesoft\Foundation\Console
 * @author   ARCANEDEV <arcanedev.maroc@gmail.com>
 */
class PublishCommand extends Command
{
    /* -----------------------------------------------------------------
     |  Properties
     | -----------------------------------------------------------------
     */

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'foundation:publish';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Publish foundation config, assets and other stuff.';

    /* -----------------------------------------------------------------
     |  Main Methods
     | -----------------------------------------------------------------
     */

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->call('vendor:publish', ['--provider' => FoundationServiceProvider::class]);

        foreach ($this->config()->get('arcanesoft.foundation.modules.commands.publish', []) as $command) {
            $this->call($command);
        }
    }
}


<?php

namespace Academe\SerializeParser;

/**
 * Given a string, this class will read through the string using
 * one of a number of terminating rules:
 * - One character.
 * - A specified number of characters.
 * - Until a matching character is found.
 */

class StringReader
{
    protected $pos = 0;
    protected $max = 0;
    protected $string = [];

    public function __construct($string)
    {
        // Split the string up into an array of UTF-8 characters.
        // As an array we can read through it one character at a time.

        //$this->string = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);
        //$this->max = count($this->string) - 1;
        $this->string = $string;
        $this->max = strlen($this->string) - 1;
    }

    /**
     * Read the next character from the supplied string.
     * Return null when we have run out of characters.
     */
    public function readOne()
    {
        if ($this->pos <= $this->max) {
            $value = $this->string[$this->pos];
            $this->pos += 1;
        } else {
            $value = null;
        }

        return $value;
    }

    /**
     * Read characters until we reach the given character $char.
     * By default, discard that final matching character and return
     * the rest.
     */
    public function readUntil($char, $discard_char = true)
    {
        $value = '';

        while(null !== ($one = $this->readOne())) {
            if ($one !== $char || !$discard_char) {
                $value .= $one;
            }

            if ($one === $char) {
                break;
            }
        }

        return $value;
    }

    /**
     * Read $count characters, or until we have reached the end,
     * whichever comes first.
     * By default, remove enclosing double-quotes from the result.
     */
    public function read($count, $strip_quotes = true)
    {
        $value = '';

        while($count > 0 && null != ($one = $this->readOne())) {
            $value .= $one;
            $count -= 1;
        }

        return $strip_quotes ? $this->stripQuotes($value) : $value;
    }

    /**
     * Remove a single set of double-quotes from around a string.
     *  abc => abc
     *  "abc" => abc
     *  ""abc"" => "abc"
     *
     * @param string string
     * @returns string
     */
    public function stripQuotes($string)
    {
        // Only remove exactly one quote from the start and the end,
        // and then only if there is one at each end.

        if (strlen($string) < 2 || substr($string, 0, 1) !== '"' || substr($string, -1, 1) !== '"') {
            // Too short, or does not start or end with a quote.
            return $string;
        }

        // Return the middle of the string, from the second character to the second-but-last.
        return substr($string, 1, -1);
    }
}


<?php

/*
 * This file is part of gpupo/search
 *
 * (c) Gilmar Pupo <contact@gpupo.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Gpupo\Search\Query;

abstract class KeywordsAbstract
{
    protected $data = [
        'key'    => '*',
        'values' => [],
        'strict' => false,
    ];

    public function addKeyword($string)
    {
        if (strlen($string) > 2) {
            $this->data['values'][] = $string;
        }

        return $this;
    }

    public function setKey($key)
    {
        $this->data['key'] = $key;
    }

    public function setStrict($bool)
    {
        $this->data['strict'] = $bool;
    }

    public function setData($key, array $values, $strict = false)
    {
        $array = [
            'key'       => $key,
            'values'    => $values,
            'strict'    => $strict,
        ];

        return $this->data = $array;
    }

    public function getData()
    {
        return $this->data;
    }

    public function getValues()
    {
        return $this->data['values'];
    }

    public function getKey()
    {
        return $this->data['key'];
    }

    /**
     * Recebe a string pesquisada.
     *
     * @param string $string
     */
    public function readString($string)
    {
        $string = str_replace(
            ["'", '"', 'buscar', '�'],
            [' ', ' ', ' ', ' '],
            strtolower(trim($string))
        );

        if (empty($string)) {
            throw new \InvalidArgumentException('Palavra chave nao pode ser vazia');
        }

        if (strlen(preg_replace('/[^A-Za-z0-9?!]/', '', $string)) < 3) {
            throw new \InvalidArgumentException('Palavra chave deve ter mais que 3 caracteres');
        }

        $array = explode(' ', $string);

        foreach ($array as $keyword) {
            $this->addKeyword($keyword);
        }

        return $this;
    }
}


<?php
/**
 * Contao Open Source CMS, Copyright (C) 2005-2015 Leo Feyer
 *
 * Module Download Statistics
 *
 * PHP version 5
 * @copyright  Glen Langer 2011..2015 <http://contao.ninja>
 * @author     Glen Langer (BugBuster)
 * @package    GLDLStats
 * @license    LGPL
 * @filesource
 * @see	       https://github.com/BugBuster1701/dlstats
 */

/**
 * Run in a custom namespace, so the class can be replaced
 */
namespace BugBuster\DLStats;

/**
 * Class ModuleDlstatsStatistics
 *
 * @copyright  Glen Langer 2011..2015 <http://contao.ninja>
 * @author     Glen Langer (BugBuster)
 * @package    GLDLStats
 */
class ModuleDlstatsStatistics extends \BackendModule
{
    /**
     * Template
     * @var string
     */
    protected $strTemplate = 'mod_dlstats_be_statistics';

    /**
     * Detailed Statistic
     * @var boolean
     */
    protected $boolDetails = true;

    protected $intTopDownloadLimit  = 20;
    protected $intLastDownloadLimit = 20;
    protected $intCalendarDaysLimit = 30;

    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();

        if ( isset($GLOBALS['TL_CONFIG']['dlstatTopDownloads'])
         && intval($GLOBALS['TL_CONFIG']['dlstatTopDownloads']) >0)
        {
            $this->intTopDownloadLimit = intval($GLOBALS['TL_CONFIG']['dlstatTopDownloads']);
        }
        if ( isset($GLOBALS['TL_CONFIG']['dlstatLastDownloads'])
                && intval($GLOBALS['TL_CONFIG']['dlstatLastDownloads']) >0)
        {
            $this->intLastDownloadLimit = intval($GLOBALS['TL_CONFIG']['dlstatLastDownloads']);
        }

        if (\Input::get('act',true)=='zero')
        {
            $this->setZero();
        }
        if (\Input::get('act',true)=='delete')
        {
            $this->deleteCounter();
        }
    }

    /**
     * Generate module
     */
    protected function compile()
    {
        $this->loadLanguageFile('tl_dlstatstatistics_stat');

        $this->Template->href   = $this->getReferer(true);
        $this->Template->status_counting = $this->getStatusCounting();
        $this->Template->status_detailed = $this->getStatusDetailed();
        $this->Template->status_anonymization = $this->getStatusAnonymization();
        $this->Template->boolDetails = $this->boolDetails;

        $this->Template->theme  = $this->getTheme();

        $this->Template->arrStatMonth     = $this->getMonth();
        $this->Template->arrStatYear      = $this->getYear();
        $this->Template->totalDownloads   = $this->getTotalDownloads();
        $this->Template->startdate        = $this->getStartDate();
        $this->Template->arrTopDownloads  = $this->getTopDownloads($this->intTopDownloadLimit);
        $this->Template->arrLastDownloads = $this->getLastDownloads($this->intLastDownloadLimit);
        $this->Template->arrCalendarDayDownloads = $this->getCalendarDayDownloads($this->intCalendarDaysLimit);

        $GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['downloads_top20']   =
            sprintf($GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['downloads_top20']  , $this->intTopDownloadLimit);
        $GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['last_20_downloads'] =
            sprintf($GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['last_20_downloads'], $this->intLastDownloadLimit);
        $GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['last_30_calendar_days'] =
            sprintf($GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['last_30_calendar_days'], $this->intCalendarDaysLimit);

        $this->Template->dlstats_version  = $GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['modname'] . ' ' . DLSTATS_VERSION .'.'. DLSTATS_BUILD;

        $this->Template->dlstats_hook_panels = $this->addStatisticPanelLineHook();

    }

    /**
     * Statistic, set on zero
     */
    protected function setZero()
    {
        \Database::getInstance()->prepare("TRUNCATE TABLE tl_dlstatdets")->execute();
        \Database::getInstance()->prepare("TRUNCATE TABLE tl_dlstats")->execute();
        return ;
    }

    /**
     * Delete a counter
     */
    protected function deleteCounter()
    {
        if ( is_null( \Input::get('dlstatsid',true) ) )
        {
            return ;
        }
        \Database::getInstance()->prepare("DELETE FROM tl_dlstatdets WHERE pid=?")
                                ->execute(\Input::get('dlstatsid',true));
        \Database::getInstance()->prepare("DELETE FROM tl_dlstats    WHERE  id=?")
                                ->execute(\Input::get('dlstatsid',true));
        return ;
    }

    /**
     * Get Counting Status
     * @return string
     */
    protected function getStatusCounting()
    {
        if ( isset($GLOBALS['TL_CONFIG']['dlstats'])
                && (bool) $GLOBALS['TL_CONFIG']['dlstats'] === true
           )
        {
            return ''.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_activated'].'';
        }
        return ''.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_deactivated'].'';
    }

    /**
     * Get Detailed Logging Status
     * @return string
     */
    protected function getStatusDetailed()
    {
        if ( isset($GLOBALS['TL_CONFIG']['dlstats'])
                && (bool) $GLOBALS['TL_CONFIG']['dlstats'] === true
          && isset($GLOBALS['TL_CONFIG']['dlstatdets'])
                && (bool) $GLOBALS['TL_CONFIG']['dlstatdets'] === true
           )
        {
            return ''.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_activated'].'';
        }
        $this->boolDetails = false;
        return ''.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_deactivated'].'';
    }

    /**
     * Get Status Anonymization
     * @return string
     */
    protected function getStatusAnonymization()
    {
        if ( isset($GLOBALS['TL_CONFIG']['privacyAnonymizeIp'])
                && (bool) $GLOBALS['TL_CONFIG']['privacyAnonymizeIp'] === true
        )
        {
            return $GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_activated'];
        }
        return $GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_deactivated'];
    }

    /**
     * Monthly Statistics, last 12 Months
     * @return array
     */
    protected function getMonth()
    {
        $arrMonth = array();
        $objMonth = \Database::getInstance()->prepare("SELECT
                                                         FROM_UNIXTIME(`tstamp`,'%Y-%m')  AS YM
                                                       , COUNT(`id`) AS SUMDL
                                                       FROM `tl_dlstatdets`
                                                       WHERE 1
                                                       GROUP BY YM
                                                       ORDER BY YM DESC")
                                            ->limit(12)
                                            ->execute();
        $intRows = $objMonth->numRows;
        if ($intRows>0)
        {
            while ($objMonth->next())
            {
                $Y = substr($objMonth->YM, 0,4);
                $M = (int)substr($objMonth->YM, -2);
                $arrMonth[] = array($Y.' '.$GLOBALS['TL_LANG']['MONTHS'][($M - 1)], $this->getFormattedNumber($objMonth->SUMDL,0) );
            }
        }

        return $arrMonth;
    }

    /**
     * Years Statistic, last 12 years
     * @return array
     */
    protected function getYear()
    {
        $arrYear = array();
        $objYear = \Database::getInstance()->prepare("SELECT
                                                        FROM_UNIXTIME(`tstamp`,'%Y')  AS Y
                                                      , COUNT(`id`) AS SUMDL
                                                      FROM `tl_dlstatdets`
                                                      WHERE 1
                                                      GROUP BY Y
                                                      ORDER BY Y DESC")
                                           ->limit(12)
                                           ->execute();
        $intRows = $objYear->numRows;
        if ($intRows>0)
        {
            while ($objYear->next())
            {
                // Y, formatierte Zahl, unformatierte Zahl
                $arrYear[] = array($objYear->Y, $this->getFormattedNumber($objYear->SUMDL,0),$objYear->SUMDL );
            }
        }

        return $arrYear;
    }

    /**
     * Total Downloads
     * @return number
     */
    protected function getTotalDownloads()
    {
        $totalDownloads = 0;
        $objTODL = \Database::getInstance()->prepare("SELECT
                                                      SUM( `downloads` ) AS TOTALDOWNLOADS
                                                      FROM `tl_dlstats`
                                                      WHERE 1")
                                           ->execute();
        $intRows = $objTODL->numRows;
        if ($intRows>0)
        {
            $totalDownloads = $this->getFormattedNumber($objTODL->TOTALDOWNLOADS,0);
        }

        return $totalDownloads;
    }

    /**
     * Get Startdate of detailed logging
     * @return string    Date
     */
    protected function getStartDate()
    {
        $StartDate = false;
        $objStartDate = \Database::getInstance()->prepare("SELECT
                                                           MIN(`tstamp`) AS YMD
                                                           FROM `tl_dlstatdets`
                                                           WHERE 1")
                                                ->execute();
        if ($objStartDate->YMD !== null)
        {
            $StartDate = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objStartDate->YMD);

        }

        return $StartDate;
    }

    /**
     * Get TOP Downloadlist
     * @param number $limit    optional
     * @return array    $arrTopDownloads
     */
    protected function getTopDownloads($limit=20)
    {
        $arrTopDownloads = array();
        $objTopDownloads = \Database::getInstance()->prepare("SELECT `tstamp`, `filename`, `downloads`, `id`
                                                              FROM `tl_dlstats`
                                                              ORDER BY `downloads` DESC")
                                                   ->limit($limit)
                                                   ->execute();
        $intRows = $objTopDownloads->numRows;
        if ($intRows>0)
        {
            while ($objTopDownloads->next())
            {
                $c4d = $this->check4details($objTopDownloads->id);
                $arrTopDownloads[] = array( $objTopDownloads->filename
                                          , $this->getFormattedNumber($objTopDownloads->downloads,0)
                                          , $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $objTopDownloads->tstamp)
                                          , $objTopDownloads->id
                                          , $c4d
                                          , $objTopDownloads->downloads //no formatted number for sorting
                                          , $objTopDownloads->tstamp //for sorting
                                          );
            }
        }

        return $arrTopDownloads;
    }

    /**
     * Get Last Downloadslist
     * @param numbner $limit    optional
     * @return array    $arrLastDownloads
     */
    protected function getLastDownloads($limit=20)
    {
        $newDate = '02.02.1971';
        $oldDate = '01.01.1970';
        $viewDate = false;
        $arrLastDownloads = array();
        $objLastDownloads = \Database::getInstance()->prepare("SELECT `tstamp`, `filename`, `downloads`, `id`
                                                               FROM `tl_dlstats`
                                                               ORDER BY `tstamp` DESC, `filename`")
                                                    ->limit($limit)
                                                    ->execute();
        $intRows = $objLastDownloads->numRows;
        if ($intRows>0)
        {
            while ($objLastDownloads->next())
            {
                $viewDate = false;
                if ($oldDate != $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objLastDownloads->tstamp))
                {
                    $newDate  = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objLastDownloads->tstamp);
                    $viewDate = $newDate;
                }
                $c4d = $this->check4details($objLastDownloads->id);
                $arrLastDownloads[] = array( $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $objLastDownloads->tstamp)
                                           , $objLastDownloads->filename
                                           , $this->getFormattedNumber($objLastDownloads->downloads,0)
                                           , $viewDate
                                           , $objLastDownloads->id
                                           , $c4d
                                           , $objLastDownloads->downloads // for sorting
                                           , $objLastDownloads->tstamp // for sorting
                                           );
                $oldDate = $newDate;
            }
        }

        return $arrLastDownloads;
    }

    /**
     * Get Number of Logged Details
     * @param number $id    pid of file
     * @return number
     */
    protected function check4details($id)
    {
        $objC4D = \Database::getInstance()->prepare("SELECT count(`id`)  AS num
                                                     FROM `tl_dlstatdets`
                                                     WHERE `pid`=?")
                                          ->execute($id);
        return $objC4D->num;
    }

    /**
     * Get Calendar Day Downloads
     *
     * @param number $limit optional
     * @return array $arrCalendarDayDownloads
     */
    protected function getCalendarDayDownloads($limit=30)
    {
        $arrCalendarDayDownloads = array();
        $CalendarDays = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")-$limit, date("Y") ) );
        $objCalendarDayDownloads = \Database::getInstance()
                                    ->prepare("SELECT dl.`id`
                                                    , FROM_UNIXTIME(det.`tstamp`,GET_FORMAT(DATE,'ISO')) as datum
                                                    , count(dl.`filename`) as downloads
                                                    , dl.`filename`
                                                FROM `tl_dlstats` dl
                                                INNER JOIN `tl_dlstatdets` det on dl.id = det.pid
                                                WHERE FROM_UNIXTIME(det.`tstamp`,GET_FORMAT(DATE,'ISO')) >=?
                                                GROUP BY dl.`id`, datum
                                                ORDER BY datum DESC, `filename`")
                                    ->execute($CalendarDays);

        while ($objCalendarDayDownloads->next())
        {
            $viewDate = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], strtotime($objCalendarDayDownloads->datum) );
            $c4d = $this->check4details($objCalendarDayDownloads->id);
            $arrCalendarDayDownloads[] = array(
                                      $viewDate
                                    , $objCalendarDayDownloads->filename
                                    , $this->getFormattedNumber($objCalendarDayDownloads->downloads,0)
                                    , $objCalendarDayDownloads->id
                                    , $c4d
                                    , $objCalendarDayDownloads->downloads
                                    , strtotime($objCalendarDayDownloads->datum)
                                );
        }

        return $arrCalendarDayDownloads;
    }

    /**
     * Hook: addStatisticPanelLine
     * Search for registered DLSTATS HOOK: addStatisticPanelLine
     *
     * @return    string    HTML5 sourcecode | false
     *
     *
     *

     *
     *

     *
     */
    protected function addStatisticPanelLineHook()
    {
        if (isset($GLOBALS['TL_DLSTATS_HOOKS']['addStatisticPanelLine'])
            && is_array($GLOBALS['TL_DLSTATS_HOOKS']['addStatisticPanelLine']))
        {
            foreach ($GLOBALS['TL_DLSTATS_HOOKS']['addStatisticPanelLine'] as $callback)
            {
                $this->import($callback[0]);
                $result[] = $this->{$callback[0]}->{$callback[1]}();
            }
            return $result;
        }
        return false;
    }
}


<?php namespace Arcanesoft\Foundation\ViewComposers\System;

use Illuminate\View\View;

/**
 * Class     FoldersPermissionsComposer
 *
 * @package  Arcanesoft\Foundation\ViewComposers\System
 * @author   ARCANEDEV <arcanedev.maroc@gmail.com>
 */
class FoldersPermissionsComposer
{
    /* -----------------------------------------------------------------
     |  Constants
     | -----------------------------------------------------------------
     */

    const VIEW = 'foundation::admin.system.information._includes.folders-permissions';

    /* -----------------------------------------------------------------
     |  Main Methods
     | -----------------------------------------------------------------
     */

    /**
     * Compose the view.
     *
     * @param  \Illuminate\View\View  $view
     */
    public function compose(View $view)
    {
        $view->with('permissions', $this->prepare([
            'storage/app/',
            'storage/framework/',
            'storage/logs/',
            'bootstrap/cache/',
        ]));
    }

    /* -----------------------------------------------------------------
     |  Other Methods
     | -----------------------------------------------------------------
     */

    /**
     * Prepare the permissions.
     *
     * @param  array  $folders
     *
     * @return \Illuminate\Support\Collection
     */
    private function prepare(array $folders)
    {
        return collect($folders)->mapWithKeys(function ($folder) {
            $path = base_path($folder);

            return [
                $folder => [
                    'chmod'    => (int) substr(sprintf('%o', fileperms($path)), -4),
                    'writable' => is_writable($path),
                ],
            ];
        });
    }
}


<?php
/**
 *
 * User: davidlin
 * Date: 6/11/2013
 * Time: 12:43 AM
 *
 */

namespace Dlin\Zendesk\Entity;

abstract class BaseEntity
{

    /**
     *
     * @var integer
     * @readonly
     */
    protected $id;

    public function __construct($id=null){
        if($id > 0){
            $this->id = $id;
        }
    }

    protected $_changes;

    protected function addChange($fieldName)
    {
        if (!is_array($this->_changes)) {
            $this->_changes = array();
        }
        $this->_changes[$fieldName] = 1;
        return $this;
    }

    public function resetChanges()
    {
        $this->_changes = array();
    }

    /**
     * @var \Dlin\Zendesk\Client\BaseClient
     */
    private  $_managingCleint;

    /**
     * @param \Dlin\Zendesk\Client\BaseClient $managingCleint
     */
    public function setManagingClient($managingCleint)
    {
        $this->_managingCleint = $managingCleint;
    }

    /**
     * @return \Dlin\Zendesk\Client\BaseClient
     */
    public function getManagingCleint()
    {
        return $this->_managingCleint;
    }

    /**
     * Convert to an object
     *
     * @return array
     */
    public function toArray($changedOnly = false, $extraData = null)
    {
        $vars = get_object_vars($this);
        $object = array();

        if (!is_array($this->_changes)) {
            $this->_changes = array();
        }

        if(is_array($extraData)){
            $vars = array_merge($vars, $extraData);
        }

        foreach ($vars as $k => $v) {
            if (strpos($k, '_') !== 0 && $v !== null && (!$changedOnly || array_key_exists($k, $this->_changes) || array_key_exists($k, $extraData) )) {
                if (is_array($v)) {
                    $subV = array();

                    foreach ($v as $sub) {
                        if (is_a($sub, 'Dlin\Zendesk\Entity\BaseEntity')) {
                            $subV[] = $sub->toArray();
                        } else {
                            $subV[] = $sub;
                        }
                    }
                    $object[$k] = $subV;
                } else if (is_a($v, 'Dlin\Zendesk\Entity\BaseEntity')) {
                    $object[$k] = $v->toArray();
                } else {
                    $object[$k] = $v;
                }
            }
        }

        return $object;
    }

    /**
     * Load data from the past array into local properties
     *
     * @param array $array
     */
    public function fromArray(array $array)
    {
        foreach ($array as $k => $v) {

            if (!is_null($v) && property_exists(get_class($this), $k)) {

                $meta = new \ReflectionProperty(get_class($this), $k);

                $info = $this->parsePropertyDocComment($meta->getDocComment());

                $type = $info['type'];

                if (strtolower($type) == "array" && $elementType = $info['array_element']) {
                    if (class_exists($elementType)) {
                        $children = array();
                        foreach ($v as $subV) {
                            $newElement = new $elementType();
                            $children[] = $newElement->fromArray($subV);
                        }
                        $this->$k = $children;

                    } else {
                        throw new \Exception('@element Class Not Found:' . $elementType);
                    }

                } else if (class_exists($type)) {
                    $typeObject = new $type();
                    $this->$k = $typeObject->fromArray($v);
                } else {
                    $this->$k = $v;
                }

            }

        }

        return $this;
    }

    /**
     *
     * Parse the property doc comment
     * @param $comment
     * @return array
     */
    protected function parsePropertyDocComment($comment)
    {
        $return = array();
        $return['type'] = preg_match('~@var (\S+)~m', $comment, $matches) ? $matches[1] : null;
        $return['array_element'] = preg_match('~@element (\S+)~m', $comment, $matches) ? $matches[1] : null;

        return $return;

    }

    /**
     * This is used to validate a field having a  value amongst a list of valid value
     *
     * @param $value
     * @param $enum
     * @throws \Exception
     */
    protected function checkEnumField($value, $enum)
    {
        if (!in_array($enum, $value)) {
            throw new \Exception("Invalid value ($value) given, valid values are:" . implode(', ', $enum));
        }
    }

    /**
     * Check if the field is Updatable or not
     *
     * @throws \Exception
     */
    protected function checkNotUpdatableField()
    {
        if (property_exists($this, 'id') && $this->id > 0) {
            throw new \Exception("Field not updatable");
        }
    }

    /**
     * Checks if this entity is creatable
     * @throws \Exception
     */
    public function checkCreatable()
    {
        if (property_exists($this, 'id') && $this->id > 0) {
            throw new \Exception(get_class($this) . " has ID:" . $this->id() . " thus not creatable.");
        }

    }

    /**
     * Checks if the fields given are all assigned
     * @param $fields
     * @throws \Exception
     */
    protected function checkFieldsSet($fields)
    {
        foreach ($fields as $field) {
            if (property_exists($this, $field) && $this->$field === null) {
                throw new \Exception("'$field' is required");
            }

        }

    }

    /**
     * @return TicketAudit
     */
    public function udpate($extraData=null)
    {
        if ($this->getManagingCleint()) {
            /**
             * @var \Dlin\Zendesk\Result\ChangeResult $result
             */
            $result = $this->getManagingCleint()->save($this, $extraData);
            if ($result) {
                $this->resetChanges();
                $this->fromArray($result->getItem()->toArray());
                return $result->getAudit();
            }
        } else {

            throw new \Exception(get_class($this) . ' can not be updated without a managing client');
        }
        return null;
    }

    /**
     * @return mixed
     * @throws \Exception
     */
    public function delete()
    {
        if ($this->getManagingCleint()) {
            /**
             * @var \Dlin\Zendesk\Result\ChangeResult $result
             */
            $result = $this->getManagingCleint()->delete($this);
            if ($result) {
                $this->id = 0;
                $this->resetChanges();
                return $result->getAudit();
            }

        } else {
            throw new \Exception(get_class($this) . ' can not be deleted without a managing client');
        }
        return null;
    }

}


<?php

/**
 * Contao Open Source CMS, Copyright (C) 2005-2015 Leo Feyer
 *
 * Modul Dlstats Tag - Frontend for InsertTags
 *
 * PHP version 5
 * @copyright  Glen Langer 2011..2015 <http://contao.ninja>
 * @author     Glen Langer (BugBuster)
 * @package    GLDLStats
 * @license    LGPL
 * @filesource
 * @see	       https://github.com/BugBuster1701/dlstats
 */

/**
 * Run in a custom namespace, so the class can be replaced
 */
namespace BugBuster\DLStats;

/**
 * Class ModuleDlstatsTag
 *
 * @copyright  Glen Langer 2012
 * @author     Glen Langer
 * @package    GLDLStats
 * @license    LGPL
 */
class ModuleDlstatsTag extends \Frontend
{

	/**
	 * replaceInsertTags
	 *
	 * From TL 2.8 you can use prefix "cache_". Thus the InserTag will be not cached. (when "cache" is enabled)
	 *
	 *       dlstats::totaldownloads::filename - Total downloads for filename
	 * cache_dlstats::totaldownloads::filename - Total downloads for filename (not cached)
	 *
	 * <code>
	 * {{cache_dlstats::totaldownloads::tl_files/cdc2010.pdf}}
	 * {{cache_dlstats::totaldownloads::CDC_2010.html?file=tl_files/cdc2010.pdf}}
	 * // in the ce_download template:
	 * {{cache_dlstats::totaldownloads::<?php echo $this->href; ?>}}
	 * // in the ce_downloads template:
	 * {{cache_dlstats::totaldownloads::<?php echo $file['href']; ?>}}
	 * </code>
	 *
	 * @param string    $strTag Insert-Tag
	 * @return mixed    integer on downloads, false on wrong Insert-Tag or wrong parameters
	 * @access public
	 */
	public function dlstatsReplaceInsertTags($strTag)
	{
		$arrTag = trimsplit('::', $strTag);
		if ($arrTag[0] != 'dlstats')
		{
			if ($arrTag[0] != 'cache_dlstats')
			{
				return false; // not for us
			}
		}
		$this->loadLanguageFile('tl_dlstats');
		if (! isset($arrTag[2]))
		{
			$this->log($GLOBALS['TL_LANG']['tl_dlstats']['no_key'], 'ModuleDlstatsTag ReplaceInsertTags ', TL_ERROR);
			return false; // da fehlt was
		}
		// filename with article alias?
		if (strpos($arrTag[2], 'file=') !== false)
		{
			$arrTag[2] = substr($arrTag[2], strpos($arrTag[2], 'file=') + 5);
		}
		if ($arrTag[1] == 'totaldownloads')
		{
			$objDlstats = \Database::getInstance()->prepare("SELECT
                                                                    `downloads`
                                                             FROM
                                                                    `tl_dlstats`
                                                             WHERE
                                                                    `filename` = ?")
                                    ->executeUncached(urldecode($arrTag[2]));
			if ($objDlstats->numRows < 1)
			{
				return 0;
			}
			$objDlstats->next();
			return $objDlstats->downloads;
		}
		// Tag is wrong
		$this->log($GLOBALS['TL_LANG']['tl_dlstats']['wrong_key'], 'ModuleDlstatsTag ReplaceInsertTags ', TL_ERROR);
		return false; // wrong tag
	} //function
} // class


<?php namespace Arcanesoft\Foundation\Console;

use Arcanesoft\Foundation\Seeds\DatabaseSeeder;

/**
 * Class     InstallCommand
 *
 * @package  Arcanesoft\Foundation\Console
 * @author   ARCANEDEV <arcanedev.maroc@gmail.com>
 */
class InstallCommand extends Command
{
    /* -----------------------------------------------------------------
     |  Properties
     | -----------------------------------------------------------------
     */

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'foundation:install';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Foundation install command.';

    /* -----------------------------------------------------------------
     |  Main Methods
     | -----------------------------------------------------------------
     */

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->arcanesoftHeader();

        if ($this->confirm('Do you wish to publish the modules ?')) {
            $this->publishAllModules();
        }

        if ($this->confirm('Do you wish to reset the migrations ?')) {
            $this->refreshMigrations();
            $this->installModules();
        }
    }

    /* -----------------------------------------------------------------
     |  Other Methods
     | -----------------------------------------------------------------
     */

    /**
     * Publish all modules: configs, migrations, assets ...
     */
    private function publishAllModules()
    {
        $this->frame('Publishing all the modules files');
        $this->line('');

        $this->call('foundation:publish');
        $this->call('optimize');

        $this->comment('All files are published !');
        $this->line('');
    }

    /**
     * Refresh migrations.
     */
    private function refreshMigrations()
    {
        $this->frame('Reseting all the migrations');
        $this->line('');

        $this->call('migrate:fresh');

        $this->line('');
    }

    /**
     * Seed all modules.
     */
    private function installModules()
    {
        $this->frame('Installing the modules');
        $this->line('');

        foreach ($this->config()->get('arcanesoft.foundation.modules.commands.install', []) as $command) {
            $this->call($command);
        }
        $this->call('db:seed', ['--class' => DatabaseSeeder::class]);

        $this->line('');
        $this->comment('Modules installed !');
        $this->line('');
    }
}


<?php

namespace Zofe\Deficient;

use Illuminate\Container\Container;
use Illuminate\Config\FileLoader;
use Illuminate\Config\Repository;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\ClassLoader;
use Illuminate\Support\Facades\Facade;
use Philo\Blade\Blade;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Zofe\Burp\Burp;

class Deficient {

    protected static $app; //container
    protected static $config; //config loader
    protected static $view; //blade

    public static function boot ($path) {

        $path = rtrim($path,'/').'/';

        $env = self::getEnv();

        self::$app = new Container;
        self::$app['app'] = self::$app;
        self::$app['env'] = $env;
        self::$app['path'] = $path;

        //config
        self::bootConfig();

        self::bootClasses();

        self::bootView();

        self::bootProviders();

        Facade::setFacadeApplication(self::$app);

    }

    //fare un setEnv con closure
    protected static function getEnv() {
        return 'production';
    }

    protected static function bootConfig() {

        $loader = new FileLoader(new Filesystem, self::$app['path'] . 'config');
        $config = new Repository($loader, self::$app['env']);

        $cg['app.locale'] = $config->get('app.locale');
        $cg['app.fallback_locale'] = $config->get('app.locale');
        $cg['app.timezone'] = $config->get('app.timezone');
        $cg['database.fetch'] = $config->get('database.fetch');

        $cg['database.default'] = $config->get('database.default');
        $cg['database.connections'] = $config->get('database.connections');
        self::$app['config'] = $cg;
        self::$config = $config;
        date_default_timezone_set($cg['app.timezone']);
    }

    protected static function bootClasses() {

        if (self::$config->get('app.autoload')) {
            $dirs = self::$config->get('app.autoload');
            ClassLoader::register();
            ClassLoader::addDirectories($dirs);
        }
    }

    protected static function bootView() {
        self::$view = new Blade(self::$app['path'].self::$config->get('app.views'),
                                self::$app['path'].self::$config->get('app.cache'));
    }

    protected static function bootProviders() {
        $providers = self::$config->get('app.providers');

        // Register all providers
        $registered = array();
        foreach ($providers as $provider)
        {
            $instance = new $provider(self::$app);
            $instance->register();
            $registered[] = $instance;
        }

        // Then boot them
        foreach ($registered as $instance)
        {
            $instance->boot();
        }

    }

    public static function View($view, $parameters = array(), $code = null, $render = true) {
        if ($code && $code == "404") header("HTTP/1.0 404 Not Found");
        $result = self::$view->view()->make($view, $parameters);
        if ($render) {
            return $result->render();
        }
        return $result;
    }

    public static function Config($value, $default = null) {
        return self::$config->get($value, $default);
    }

    public static function app($item = null) {
        if ($item) {
            return self::$app['app'][$item];
        }
        return self::$app['app'];
    }
}


<?php
namespace Avatar4eg\Transliterator\Api\Controller;

use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Repository\DiscussionRepository;
use Flarum\Http\Controller\ControllerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Zend\Diactoros\Response\JsonResponse;
use Illuminate\Contracts\Bus\Dispatcher;
use Flarum\Core\Command\EditDiscussion;
use Behat\Transliterator\Transliterator;

class ParseSlugController implements ControllerInterface
{
    use AssertPermissionTrait;

    /**
     * @var TranslatorInterface
     */
    protected $translator;

    /**
     * @var DiscussionRepository
     */
    protected $discussions;

    /**
     * @var Dispatcher
     */
    protected $bus;

    /**
     * @param TranslatorInterface $translator
     * @param DiscussionRepository $discussions
     * @param Dispatcher $bus
     */
    public function __construct(TranslatorInterface $translator, DiscussionRepository $discussions, Dispatcher $bus)
    {
        $this->translator = $translator;
        $this->discussions = $discussions;
        $this->bus = $bus;
    }

    /**
     * {@inheritdoc}
     * @throws \InvalidArgumentException
     */
    public function handle(ServerRequestInterface $request)
    {
        $actor = $request->getAttribute('actor');
        $result = false;
        $counter = 0;

        if ($actor !== null && $actor->isAdmin() && $request->getMethod() === 'POST') {
            $discussions = $this->discussions->query()->whereVisibleTo($actor)->get();
            foreach ($discussions as $discussion) {
                $slug = Transliterator::transliterate($discussion->title);
                if ($discussion->slug !== $slug) {
                    $data = [
                        'type' => 'discussions',
                        'id' => $discussion->id,
                        'attributes' => [
                            'title' => $discussion->title
                        ]
                    ];
                    $this->bus->dispatch(
                        new EditDiscussion($discussion->id, $actor, $data)
                    );
                    $counter++;
                }
            }
            $result = true;
        }

        $string = $this->translator->trans('avatar4eg-transliterator.admin.settings.result');
        return new JsonResponse([
            'success'   => $result,
            'message'   => "$string $counter"
        ]);
    }
}


<?php

namespace Bavix\Router;

use Bavix\Router\Rules\PatternRule;

class Match implements \Serializable, \JsonSerializable
{

    /**
     * @var array
     */
    protected $urlData;

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

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

    /**
     * @var array
     */
    protected $attributes = [];

    /**
     * @var array
     */
    protected $groups = [];

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

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

    /**
     * @var PatternRule
     */
    protected $rule;

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

    /**
     * @param PatternRule $rule
     * @param string $subject
     * @param string $method
     */
    public function __construct(PatternRule $rule, string $subject, string $method)
    {
        $this->attributes = $rule->getDefaults();
        $this->urlData = \parse_url($subject);
        $this->rule = $rule;
        $this->method = $method;
        $this->subject = $subject;
        $this->test();
    }

    /**
     * check subject
     */
    protected function test(): void
    {
        if (!$this->methodAllowed()) {
            return;
        }

        $result = \preg_match($this->regex(), $this->subject, $matches);
        $this->test = $result !== 0;
        $this->setGroups(\array_filter(
            $matches,
            '\is_string',
            \ARRAY_FILTER_USE_KEY
        ));
    }

    /**
     * check method
     *
     * @return bool
     */
    protected function methodAllowed(): bool
    {
        $this->test = $this->rule->getMethods() === null ||
            \in_array($this->method, $this->rule->getMethods(), true);

        return $this->isTest();
    }

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

    /**
     * @return string
     */
    protected function regex(): string
    {
        return '~^' . $this->getPattern() . '$~u';
    }

    /**
     * @return string
     */
    public function getPattern(): string
    {
        return Server::url(
            $this->rule->getPath()->getPattern(),
            $this->rule->getHost(),
            $this->rule->getProtocol()
        );
    }

    /**
     * @return string
     */
    public function getMethod(): string
    {
        return $this->method;
    }

    /**
     * @return array
     */
    public function getGroups(): array
    {
        return $this->groups;
    }

    /**
     * @param array $groups
     */
    protected function setGroups(array $groups): void
    {
        foreach ($groups as $key => $value) {
            if ($value !== '') {
                $this->groups[$key] = $value;
            }
        }

        $this->attributes = \array_merge(
            $this->attributes,
            $this->groups
        );
    }

    /**
     * @return string
     */
    public function getProtocol(): ?string
    {
        return $this->urlData['scheme'] ?? null;
    }

    /**
     * @return string
     */
    public function getHost(): ?string
    {
        return $this->urlData['host'] ?? null;
    }

    /**
     * @return string
     */
    public function getPath(): ?string
    {
        return $this->urlData['path'] ?? null;
    }

    /**
     * @return string
     */
    public function getQuery(): string
    {
        return $this->urlData['query'] ?? null;
    }

    /**
     * @return string
     */
    public function getSubject(): string
    {
        return $this->subject;
    }

    /**
     * @return PatternRule
     */
    public function getRule(): PatternRule
    {
        return $this->rule;
    }

    /**
     * @return array
     */
    public function getAttributes(): array
    {
        return $this->attributes;
    }

    /**
     * @return array
     */
    public function __sleep(): array
    {
        return \array_keys($this->jsonSerialize());
    }

    /**
     * @inheritdoc
     */
    public function jsonSerialize(): array
    {
        return [
            'urlData' => $this->urlData,
            'protocol' => $this->protocol,
            'host' => $this->host,
            'attributes ' => $this->attributes,
            'method' => $this->method,
            'subject' => $this->subject,
            'rule' => $this->rule,
            'test' => $this->test,
        ];
    }

    /**
     * @inheritdoc
     */
    public function serialize(): string
    {
        return \serialize($this->jsonSerialize());
    }

    /**
     * @inheritdoc
     */
    public function unserialize($serialized): void
    {
        $data = \unserialize($serialized, (array)null);
        foreach ($data as $key => $value) {
            $this->{$key} = $value;
        }
    }

}


<?php

/*
 * This file is part of gpupo/search
 *
 * (c) Gilmar Pupo <contact@gpupo.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Gpupo\Search\Paginator;

use Gpupo\Search\Result\CollectionInterface;

class Paginator extends PaginatorAbstract implements PaginatorInterface
{
    public function paginateResult(CollectionInterface $collection, $page, $limit = 10)
    {
        $limit = intval(abs($limit));
        if (!$limit) {
            throw new \LogicException('Invalid item per page number, must be a positive number');
        }

        $this->paginate($collection->getTotalFound(), $page, $limit);

        return $this;
    }

    public function getPaginationData()
    {
        $pages = $this->getPages();

        $viewData = [
            'last'              => $this->getPagesCount(),
            'current'           => $this->getCurrentPageNumber(),
            'numItemsPerPage'   => $this->getItemNumberPerPage(),
            'first'             => 1,
            'pageCount'         => $this->getPagesCount(),
            'totalCount'        => $this->getTotalItemCount(),
        ];

        if ($this->getCurrentPageNumber() - 1 > 0) {
            $viewData['previous'] = $this->getCurrentPageNumber() - 1;
        }

        if ($this->getCurrentPageNumber() + 1 <= $this->getPagesCount()) {
            $viewData['next'] = $this->getCurrentPageNumber() + 1;
        }
        $viewData['pagesInRange'] = $pages;
        $viewData['firstPageInRange'] = min($pages);
        $viewData['lastPageInRange']  = max($pages);

        return $viewData;
    }

    /**
     * Acesso ao range de paginas para navegacao.
     *
     * @return array
     */
    public function getPages()
    {
        if ($this->getPageRange() > $this->getPagesCount()) {
            $this->setPageRange($this->getPagesCount());
        }

        $delta = ceil($this->getPageRange() / 2);

        if ($this->getCurrentPageNumber() - $delta > $this->getPagesCount() - $this->getPageRange()) {
            $pages = range($this->getPagesCount() - $this->getPageRange() + 1, $this->getPagesCount());
        } else {
            if ($this->getCurrentPageNumber() - $delta < 0) {
                $delta = $this->getCurrentPageNumber();
            }

            $offset = $this->getCurrentPageNumber() - $delta;
            $pages = range($offset + 1, $offset + $this->getPageRange());
        }

        return $pages;
    }
}


<?php

/**
 * Contao Open Source CMS, Copyright (C) 2005-2015 Leo Feyer
 *
 * Module Download Statistics
 * Check the required extensions
 *
 * @copyright  Glen Langer 2011..2015 <http://contao.ninja>
 * @author     Glen Langer (BugBuster)
 * @package    GLDLStats
 * @license    LGPL
 * @filesource
 * @see	       https://github.com/BugBuster1701/dlstats
 */

/**
 * Run in a custom namespace, so the class can be replaced
 */
namespace BugBuster\DLStats;

/**
 * Class DlstatsCheck
 *
 * @copyright  Glen Langer 2011..2015 <http://contao.ninja>
 * @author     Glen Langer (BugBuster)
 * @package    GLDLStats
 */
class DlstatsCheck extends \System
{
    /**
	 * Current object instance
	 * @var object
	 */
    protected static $instance = null;

    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Return the current object instance (Singleton)
     * @return BotStatisticsHelper
     */
    public static function getInstance()
    {
        if (self::$instance === null)
        {
            self::$instance = new DlstatsCheck();
        }

        return self::$instance;
    }

    /**
     * Hook: Check the required extensions and files for BotStatistics
     *
     * @param string $strContent
     * @param string $strTemplate
     * @return string
     */
    public function checkExtensions($strContent, $strTemplate)
    {
        if ($strTemplate == 'be_main')
        {
            if ( isset($GLOBALS['TL_CONFIG']['dlstatDisableBotdetection']) &&
                (bool) $GLOBALS['TL_CONFIG']['dlstatDisableBotdetection'] === true )
            {
                return $strContent;
            }

            if (!is_array($_SESSION["TL_INFO"]))
            {
                $_SESSION["TL_INFO"] = array();
            }

            // required extensions
            $arrRequiredExtensions = array(
                    'BotDetection' => 'botdetection'
            );

            // check for required extensions
            foreach ($arrRequiredExtensions as $key => $val)
            {
                if (!in_array($val, \Config::getInstance()->getActiveModules() ))
                {
                    $_SESSION["TL_INFO"] = array_merge($_SESSION["TL_INFO"], array($val => 'Please install the required extension <strong>' . $key . '</strong> for the extension dlstats.'));
                }
                else
                {
                    if (is_array($_SESSION["TL_INFO"]) && key_exists($val, $_SESSION["TL_INFO"]))
                    {
                        unset($_SESSION["TL_INFO"][$val]);
                    }
                }
            }
        }

        return $strContent;
    } // checkExtension

} // class


<?php namespace Arcanesoft\Foundation\Providers;

use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;
use Arcanesoft\Foundation\Policies\LogViewerPolicy;
use Arcanesoft\Foundation\Policies\RouteViewerPolicy;

/**
 * Class     AuthorizationServiceProvider
 *
 * @package  Arcanesoft\Foundation\Providers
 * @author   ARCANEDEV <arcanedev.maroc@gmail.com>
 */
class AuthorizationServiceProvider extends ServiceProvider
{
    /* -----------------------------------------------------------------
     |  Main Methods
     | -----------------------------------------------------------------
     */

    /**
     * Register any application authentication / authorization services.
     */
    public function boot()
    {
        $this->registerPolicies();

        $this->defineMany(LogViewerPolicy::class, LogViewerPolicy::policies());
        $this->defineMany(RouteViewerPolicy::class, RouteViewerPolicy::policies());

        // TODO: Add more policies for other foundation features.
    }
}