<?php
namespace SlimApi\Service;

use SlimApi\Interfaces\GeneratorServiceInterface;

class DependencyService implements GeneratorServiceInterface
{
    public $commands   = [];
    private $templates = [];

    /**
     * @param string $dependencyFileLocation
     * @param string $namespaceRoot
     *
     * @return void
     */
    public function __construct($dependencyFileLocation, $namespaceRoot)
    {
        $this->dependencyFileLocation       = $dependencyFileLocation;
        $this->namespaceRoot                = $namespaceRoot;
    }

    /**
     * {@inheritdoc}
     */
    public function processCommand($type, ...$arguments)
    {
        $name = array_shift($arguments);
        $template = $this->fetch($type);
        if ($template) {
            $this->addDependency($name, $template);
        } else {
            throw new \Exception('Invalid dependency command.');
        }
    }

    /**
     * {@inheritdoc}
     */
    public function create($name, $options = [])
    {
        $content        = PHP_EOL.implode(PHP_EOL.PHP_EOL, $this->commands);
        $this->commands = [];
        $origContent = file($this->targetLocation($name));
        // insert content just before the return statement
        // @todo: something neater?
        array_splice($origContent, count($origContent)-2, 0, $content);
        return file_put_contents($this->targetLocation($name), $origContent);
    }

    /**
     * {@inheritdoc}
     */
    public function targetLocation($name)
    {
        return $this->dependencyFileLocation;
    }

    /**
     * Add the dependency processed template to our command array
     *
     * @param string $name
     * @param string $template
     *
     * @return void
     */
    private function addDependency($name, $template)
    {
        $this->commands[] = strtr($template, ['$namespace' => $this->namespaceRoot, '$name' => $name]);
    }

    /**
     * Fetches appropriate template
     *
     * @param string $name
     *
     * @return GeneratorInterface|false the required template or false if none.
     */
    public function fetch($name)
    {
        $template = false;
        if (array_key_exists($name, $this->templates)) {
            $template = $this->templates[$name];
        }
        return $template;
    }

    /**
     * Add a template to the factory
     *
     * @param string   $name      the name of the Generator
     * @param string   $template  the template to return for the specified name
     */
    public function add($name, $template)
    {
        if (array_key_exists($name, $this->templates)) {
            throw new \InvalidArgumentException('Template already exists.');
        }

        $this->templates[$name] = $template;
    }
}


<?php
namespace SlimApi\Command;

use \Exception;
use SlimApi\Skeleton\SkeletonInterface;
use SlimApi\Migration\MigrationInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class InitDbCommand extends Command
{
    public static $successMessage = "Database initiated successfully!";

    /**
     * {@inheritdoc}
     */
    public function __construct(MigrationInterface $databaseService)
    {
        parent::__construct();
        $this->databaseService = $databaseService;
    }

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('init:db')
            ->setDescription('Initiates the db setup.')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (false === is_file('composer.json')) {
            throw new Exception('Commands must be run from root of project.');
        }

        try {
            $this->databaseService->init(getcwd());
            $output->writeln('<info>'.static::$successMessage.'</info>');
        } catch (Exception $e) {
            $output->writeln($e->getMessage());
        }
    }
}


<?php
/**
 * Part of the Joomla Framework OpenStreetMap Package
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\OpenStreetMap;

/**
 * OpenStreetMap API Changesets class for the Joomla Framework
 *
 * @since       1.0
 * @deprecated  The joomla/openstreetmap package is deprecated
 */
class Changesets extends OpenStreetMapObject
{
	/**
	 * Method to create a changeset
	 *
	 * @param   array  $changesets  Array which contains changeset data
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function createChangeset($changesets=array())
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token'        => $token['key'],
			'oauth_token_secret' => $token['secret'],
		);

		// Set the API base
		$base = 'changeset/create';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$xml = '<?xml version="1.0" encoding="UTF-8"?>
			<osm version="0.6" generator="JoomlaOpenStreetMap">';

		if (!empty($changesets))
		{
			// Create Changeset element for every changeset
			foreach ($changesets as $tags)
			{
				$xml .= '<changeset>';

				if (!empty($tags))
				{
					// Create a list of tags for each changeset
					foreach ($tags as $key => $value)
					{
						$xml .= '<tag k="' . $key . '" v="' . $value . '"/>';
					}
				}

				$xml .= '</changeset>';
			}
		}

		$xml .= '</osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		return $response->body;
	}

	/**
	 * Method to read a changeset
	 *
	 * @param   integer  $id  identifier of the changeset
	 *
	 * @return  array  The XML response about a changeset
	 *
	 * @since   1.0
	 */
	public function readChangeset($id)
	{
		// Set the API base
		$base = 'changeset/' . $id;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->changeset;
	}

	/**
	 * Method to update a changeset
	 *
	 * @param   integer  $id    Identifier of the changeset
	 * @param   array    $tags  Array of tags to update
	 *
	 * @return  array  The XML response of updated changeset
	 *
	 * @since   1.0
	 */
	public function updateChangeset($id, $tags = array())
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'changeset/' . $id;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Create a list of tags to update changeset
		$tagList = '';

		if (!empty($tags))
		{
			foreach ($tags as $key => $value)
			{
				$tagList .= '<tag k="' . $key . '" v="' . $value . '"/>';
			}
		}

		$xml = '<?xml version="1.0" encoding="UTF-8"?>
				<osm version="0.6" generator="JoomlaOpenStreetMap">
				<changeset>'
				. $tagList .
				'</changeset>
				</osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		$xmlString = simplexml_load_string($response->body);

		return $xmlString->changeset;
	}

	/**
	 * Method to close a changeset
	 *
	 * @param   integer  $id  identifier of the changeset
	 *
	 * @return  void
	 *
	 * @since   1.0
	 */
	public function closeChangeset($id)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'changeset/' . $id . '/close';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$header['format'] = 'text/xml';

		// Send the request.
		$this->oauth->oauthRequest($path, 'PUT', $parameters, $header);
	}

	/**
	 * Method to download a changeset
	 *
	 * @param   integer  $id  Identifier of the changeset
	 *
	 * @return  array  The XML response of requested changeset
	 *
	 * @since   1.0
	 */
	public function downloadChangeset($id)
	{
		// Set the API base
		$base = 'changeset/' . $id . '/download';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->create;
	}

	/**
	 * Method to expand the bounding box of a changeset
	 *
	 * @param   integer  $id     Identifier of the changeset
	 * @param   array    $nodes  List of lat lon about nodes
	 *
	 * @return  array  The XML response of changed changeset
	 *
	 * @since   1.0
	 */
	public function expandBBoxChangeset($id, $nodes)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'changeset/' . $id . '/expand_bbox';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Create a list of tags to update changeset
		$nodeList = '';

		if (!empty($nodes))
		{
			foreach ($nodes as $node)
			{
				$nodeList .= '<node lat="' . $node[0] . '" lon="' . $node[1] . '"/>';
			}
		}

		$xml = '<?xml version="1.0" encoding="UTF-8"?>
				<osm version="0.6" generator="JoomlaOpenStreetMap">
				<changeset>'
				. $nodeList .
				'</changeset>
			</osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);

		$xmlString = simplexml_load_string($response->body);

		return $xmlString->changeset;
	}

	/**
	 * Method to query on changesets
	 *
	 * @param   string  $param  Parameters for query
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function queryChangeset($param)
	{
		// Set the API base
		$base = 'changesets/' . $param;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->osm;
	}

	/**
	 * Method to upload a diff to a changeset
	 *
	 * @param   string   $xml  Diff data to upload
	 * @param   integer  $id   Identifier of the changeset
	 *
	 * @return  array  The XML response of result
	 *
	 * @since   1.0
	 */
	public function diffUploadChangeset($xml, $id)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'changeset/' . $id . '/upload';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);

		$xmlString = simplexml_load_string($response->body);

		return $xmlString->diffResult;
	}
}


<?php
/**
 * Part of the Joomla Framework OpenStreetMap Package
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\OpenStreetMap;

/**
 * OpenStreetMap API User class for the Joomla Framework
 *
 * @since       1.0
 * @deprecated  The joomla/openstreetmap package is deprecated
 */
class User extends OpenStreetMapObject
{
	/**
	 * Method to get user details
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function getDetails()
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'user/details';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'GET', $parameters);

		return $response->body;
	}

	/**
	 * Method to get preferences
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function getPreferences()
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'user/preferences';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'GET', $parameters);

		return $response->body;
	}

	/**
	 * Method to replace user preferences
	 *
	 * @param   array  $preferences  Array of new preferences
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function replacePreferences($preferences)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'user/preferences';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Create a list of preferences
		$preferenceList = '';

		if (!empty($preferences))
		{
			foreach ($preferences as $key => $value)
			{
				$preferenceList .= '<preference k="' . $key . '" v="' . $value . '"/>';
			}
		}

		$xml = '<?xml version="1.0" encoding="UTF-8"?>
			<osm version="0.6" generator="JoomlaOpenStreetMap">
				<preferences>'
				. $preferenceList .
				'</preferences>
			</osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		return $response->body;
	}

	/**
	 * Method to change user preferences
	 *
	 * @param   string  $key         Key of the preference
	 * @param   string  $preference  New value for preference
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function changePreference($key, $preference)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'user/preferences/' . $key;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $preference);

		return $response->body;
	}
}


<?php
/**
 * Part of the Joomla Framework OpenStreetMap Package
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\OpenStreetMap;

use Joomla\Http\Response;

/**
 * OpenStreetMap API GPS class for the Joomla Framework
 *
 * @since       1.0
 * @deprecated  The joomla/openstreetmap package is deprecated
 */
class Gps extends OpenStreetMapObject
{
	/**
	 * Method to retrieve GPS points
	 *
	 * @param   float    $left    Left boundary
	 * @param   float    $bottom  Bottom boundary
	 * @param   float    $right   Right boundary
	 * @param   float    $top     Top boundary
	 * @param   integer  $page    Page number
	 *
	 * @return	array  The XML response containing GPS points
	 *
	 * @since	1.0
	 */
	public function retrieveGps($left, $bottom, $right, $top, $page = 0)
	{
		// Set the API base
		$base = 'trackpoints?bbox=' . $left . ',' . $bottom . ',' . $right . ',' . $top . '&page=' . $page;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'GET', array());

		return simplexml_load_string($response->body);
	}

	/**
	 * Method to upload GPS Traces
	 *
	 * @param   string   $file         File name that contains trace points
	 * @param   string   $description  Description on trace points
	 * @param   string   $tags         Tags for trace
	 * @param   integer  $public       1 for public, 0 for private
	 * @param   string   $visibility   One of the following: private, public, trackable, identifiable
	 * @param   string   $username     Username
	 * @param   string   $password     Password
	 *
	 * @return  Response  The response
	 *
	 * @since   1.0
	 */
	public function uploadTrace($file, $description, $tags, $public, $visibility, $username, $password)
	{
		// Set parameters.
		$parameters = array(
			'file'        => $file,
			'description' => $description,
			'tags'        => $tags,
			'public'      => $public,
			'visibility'  => $visibility,
		);

		// Set the API base
		$base = 'gpx/create';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$header['Content-Type'] = 'multipart/form-data';

		$header = array_merge($header, $parameters);
		$header = array_merge($header, array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));

		// Send the request.
		return $this->sendRequest($path, 'POST', $header, array());
	}

	/**
	 * Method to download Trace details
	 *
	 * @param   integer  $id        Trace identifier
	 * @param   string   $username  Username
	 * @param   string   $password  Password
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function downloadTraceMetadetails($id, $username, $password)
	{
		// Set the API base
		$base = 'gpx/' . $id . '/details';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		return $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
	}

	/**
	 * Method to download Trace data
	 *
	 * @param   integer  $id        Trace identifier
	 * @param   string   $username  Username
	 * @param   string   $password  Password
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function downloadTraceMetadata($id, $username, $password)
	{
		// Set the API base
		$base = 'gpx/' . $id . '/data';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		return $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password)));
	}
}


<?php
namespace Talevskiigor\ComposerBump;

use Illuminate\Support\ServiceProvider;

class ComposerBumpServiceProvider extends ServiceProvider
{

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {

        $this->mergeConfigFrom(
            __DIR__ . '/config.php', 'ComposerBump'
        );

        $this->publishes([
            __DIR__ . '/config.php' => config_path('composerbump.php'),
        ]);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {

        $this->app->bind('ComposerBump', \Talevskiigor\ComposerBump\ComposerBump::class);

        $this->registerBumpGenerator();

        $this->registerBumpPatchGenerator();

        $this->registerBumpMinorGenerator();

        $this->registerBumpMajorGenerator();

        $this->registerUndoBump();
    }

    private function registerBumpGenerator()
    {
        $this->app->singleton('bump.bump', function ($app) {
            return $app['Talevskiigor\ComposerBump\Commands\BumpCommand'];
        });

        $this->commands('bump.bump');
    }

    private function registerBumpPatchGenerator()
    {
        $this->app->singleton('bump.bump.patch', function ($app) {
            return $app['Talevskiigor\ComposerBump\Commands\BumpPatchCommand'];
        });

        $this->commands('bump.bump.patch');
    }

    private function registerBumpMinorGenerator()
    {
        $this->app->singleton('bump.bump.minor', function ($app) {
            return $app['Talevskiigor\ComposerBump\Commands\BumpMinorCommand'];
        });

        $this->commands('bump.bump.minor');
    }

    private function registerBumpMajorGenerator()
    {
        $this->app->singleton('bump.bump.major', function ($app) {
            return $app['Talevskiigor\ComposerBump\Commands\BumpMajorCommand'];
        });

        $this->commands('bump.bump.major');
    }

    private function registerUndoBump()
    {
        $this->app->singleton('bump.bump.undo', function ($app) {
            return $app['Talevskiigor\ComposerBump\Commands\UndoBumpCommand'];
        });

        $this->commands('bump.bump.undo');
    }
}


<?php
/* ===========================================================================
 * Copyright 2013-2016 The Opis Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Config\Drivers;

use Opis\Config\ConfigInterface;
use Opis\Config\ConfigHelper;

class Ephemeral implements ConfigInterface
{

    protected $config;

    /**
     * Memory constructor.
     * @param array|object $config
     */
    public function __construct($config = [])
    {
        $this->config = new ConfigHelper($config);
    }

    /**
     * {@inheritdoc}
     */
    public function write(string $name, $value) : bool
    {
        return $this->config->set($name, $value);
    }

    /**
     * {@inheritdoc}
     */
    public function read(string $name, $default = null)
    {
        return $this->config->get($name, $default);
    }

    /**
     * {@inheritdoc}
     */
    public function has(string $name) : bool
    {
        return $this->config->has($name);
    }

    /**
     * {@inheritdoc}
     */
    public function delete(string $name) : bool
    {
        return $this->config->delete($name);
    }
}


<?php
/**
 * Class Mock
 *
 * @author: Jiří Šifalda <sifalda.jiri@gmail.com>
 * @date: 08.09.13
 */
namespace Flame\Modules\Application\Routers;

use Nette\Application\IRouter;
use Nette\Application\Request;
use Nette\InvalidStateException;
use Nette\Object;
use Nette\Reflection\ClassType;
use Nette;

class RouteMock extends Object implements IRouteMock, IRouter
{

	/** @var string  */
	public $class;

	/** @var array  */
	public $args;

	/** @var  IRouter */
	private $router;

	/**
	 * @param string $class
	 * @param array $args
	 */
	function __construct($class, array $args = array())
	{
		$this->args = $args;
		$this->class = (string) $class;
	}

	/**
	 * @return IRouter
	 * @throws \Nette\InvalidStateException
	 */
	public function getRouter()
	{
		if($this->router === null) {
			$this->router = $this->createInstance();
		}

		if($this->router instanceof IRouter) {
			return $this->router;
		}

		throw new InvalidStateException('Class "' . $this->class . '" is not instance of Nette\Application\IRouter');
	}

	/**
	 * @return object
	 * @throws \Nette\InvalidStateException
	 */
	protected function createInstance()
	{
		if(!class_exists($this->class)) {
			throw new InvalidStateException('Route class "' . $this->class . '" not found!');
		}

		$route = new ClassType($this->class);
		return $route->newInstanceArgs($this->args);
	}

	/**
	 * Maps HTTP request to a Request object.
	 *
	 * @return Request|NULL
	 */
	function match(Nette\Http\IRequest $httpRequest)
	{
		return $this->getRouter()->match($httpRequest);
	}

	/**
	 * Constructs absolute URL from Request object.
	 *
	 * @return string|NULL
	 */
	function constructUrl(Request $appRequest, Nette\Http\Url $refUrl)
	{
		return $this->getRouter()->constructUrl($appRequest, $refUrl);
	}
}


<?php
/* ===========================================================================
 * Copyright 2013-2016 The Opis Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Config\Drivers;

use Opis\Config\ConfigInterface;

class DualStore implements ConfigInterface
{

    /** @var ConfigInterface Primary storage */
    protected $primary;

    /** @var ConfigInterface Secondary storage */
    protected $secondary;

    /** @var bool Auto-sync storages */
    protected $autoSync;

    /**
     * DualConfig constructor.
     * @param ConfigInterface $primary
     * @param ConfigInterface $secondary
     * @param bool $autosync
     */
    public function __construct(ConfigInterface $primary, ConfigInterface $secondary, bool $autosync = true)
    {
        $this->primary = $primary;
        $this->secondary = $secondary;
        $this->autoSync = $autosync;
    }

    /**
     * {@inheritdoc}
     */
    public function write(string $name, $value) : bool
    {
        if($this->primary->write($name, $value)){
            return $this->secondary->write($name, $value);
        }

        return false;
    }

    /**
     * {@inheritdoc}
     */
    public function read(string $name, $default = null)
    {
        $val = $this->primary->read($name, $this);

        if ($val === $this) {
            $val = $this->secondary->read($name, $default);

            if ($this->autoSync) {
                $this->primary->write($name, $val);
            }
        }

        return $val;
    }

    /**
     * {@inheritdoc}
     */
    public function has(string $name) : bool
    {
        return $this->primary->has($name) || $this->secondary->has($name);
    }

    /**
     * {@inheritdoc}
     */
    public function delete(string $name) : bool
    {
        $p = $this->primary->delete($name);
        $s = $this->secondary->delete($name);
        return $p && $s;
    }
}


<?php
/**
 * Class ModulesExtension
 *
 * @author: Jiří Šifalda <sifalda.jiri@gmail.com>
 * @date: 20.07.13
 */
namespace Flame\Modules\DI;

use Flame\Modules\Configurators\ErrorPresenterConfig;
use Flame\Modules\Configurators\LatteMacrosConfig;
use Flame\Modules\Configurators\ParametersConfig;
use Flame\Modules\Configurators\PresenterMappingConfig;
use Flame\Modules\Configurators\TemplateHelpersConfig;
use Flame\Modules\Configurators\TracyBarPanelsConfig;
use Flame\Modules\Configurators\TracyPanelsConfig;
use Flame\Modules\Providers\IErrorPresenterProvider;
use Flame\Modules\Providers\ILatteMacrosProvider;
use Flame\Modules\Providers\IParametersProvider;
use Flame\Modules\Providers\IRouterProvider;
use Flame\Modules\Providers\IPresenterMappingProvider;
use Flame\Modules\Providers\ITemplateHelpersProvider;
use Flame\Modules\Providers\ITracyBarPanelsProvider;
use Flame\Modules\Providers\ITracyPanelsProvider;
use Nette;
use Nette\DI\ServiceDefinition;
use Nette\Utils\Validators;

class ModulesExtension extends Nette\DI\CompilerExtension
{
	const TAG_ROUTER = 'flame.modules.router';

	public function loadConfiguration()
	{
		foreach ($this->compiler->getExtensions() as $extension) {
			if ($extension instanceof IParametersProvider) {
				$this->setupParameters($extension);
			}

			if ($extension instanceof IPresenterMappingProvider) {
				$this->setupPresenterMapping($extension);
			}

			if ($extension instanceof IRouterProvider) {
				$this->setupRouter($extension);
			}

			if ($extension instanceof ILatteMacrosProvider) {
				$this->setupMacros($extension);
			}

			if ($extension instanceof ITemplateHelpersProvider) {
				$this->setupHelpers($extension);
			}

			if ($extension instanceof IErrorPresenterProvider){
				$this->setupErrorPresenter($extension);
			}
		}
	}

	public function beforeCompile()
	{
		// Loads all services tagged as router
		$this->addRouters();
	}

	/**
	 * @param Nette\PhpGenerator\ClassType $class
	 */
	public function afterCompile(Nette\PhpGenerator\ClassType $class)
	{
		$builder = $this->getContainerBuilder();

		if ($builder->parameters['debugMode']) {

			foreach ($this->compiler->getExtensions() as $extension) {
				if ($extension instanceof ITracyBarPanelsProvider) {
					$this->setupTracyBarPanels($extension, $class);
				}

				if ($extension instanceof ITracyPanelsProvider) {
					$this->setupTracyPanels($extension, $class);
				}
			}
		}
	}

	/**
	 * @param ITracyBarPanelsProvider $extension
	 * @param Nette\PhpGenerator\ClassType $class
	 * @throws Nette\Utils\AssertionException
	 */
	private function setupTracyBarPanels(ITracyBarPanelsProvider $extension, Nette\PhpGenerator\ClassType $class)
	{
		$config = new TracyBarPanelsConfig();
		$extension->setupTracyBarPanels($config);
		$panels = $config->getConfiguration();
		Validators::assert($panels, 'array');

		$builder = $this->getContainerBuilder();
		$initialize = $class->methods['initialize'];

		foreach ($panels as $item) {
			$initialize->addBody($builder->formatPhp(
				'Tracy\Debugger::getBar()->addPanel(?);',
				Nette\DI\Compiler::filterArguments(array(is_string($item) ? new Nette\DI\Statement($item) : $item))
			));
		}

	}

	private function setupTracyPanels(ITracyPanelsProvider $extension, Nette\PhpGenerator\ClassType $class)
	{
		$config = new TracyPanelsConfig();
		$extension->setupTracyPanels($config);
		$panels = $config->getConfiguration();

		$builder = $this->getContainerBuilder();
		$initialize = $class->methods['initialize'];

		foreach ($panels as $item) {
			$initialize->addBody($builder->formatPhp(
				'Tracy\Debugger::getBlueScreen()->addPanel(?);',
				Nette\DI\Compiler::filterArguments(array($item))
			));
		}
	}

	/**
	 * @param IParametersProvider $extension
	 * @throws Nette\Utils\AssertionException
	 */
	private function setupParameters(IParametersProvider $extension)
	{
		$config = new ParametersConfig();
		$extension->setupParameters($config);
		$parameters = $config->getConfiguration();
		Validators::assert($parameters, 'array', 'parameters');

		$builder = $this->getContainerBuilder();
		if (count($parameters)) {
			$builder->parameters = Nette\DI\Config\Helpers::merge($builder->expand($parameters), $builder->parameters);
		}
	}

	/**
	 * @param ILatteMacrosProvider $extension
	 * @throws Nette\Utils\AssertionException
	 */
	private function setupMacros(ILatteMacrosProvider $extension)
	{
		$config = new LatteMacrosConfig();
		$extension->setupMacros($config);
		$macros = $config->getConfiguration();

		Validators::assert($macros, 'array', 'macros');

		$latteFactory = $this->getLatteFactory();
		foreach ($macros as $macro) {
			if (strpos($macro, '::') === FALSE && class_exists($macro)) {
				$macro .= '::install';

			} else {
				Validators::assert($macro, 'callable', 'macro');
			}

			$latteFactory->addSetup('?->onCompile[] = function($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self'));
		}
	}

	/**
	 * @param ITemplateHelpersProvider $extension
	 * @throws Nette\Utils\AssertionException
	 */
	private function setupHelpers(ITemplateHelpersProvider $extension)
	{

		$config = new TemplateHelpersConfig();
		$extension->setupHelpers($config);
		$helpers = $config->getConfiguration();
		Validators::assert($helpers, 'array', 'helpers');

		$builder = $this->getContainerBuilder();
		$latteFactory = $this->getLatteFactory();
		if (count($helpers)) {
			foreach ($helpers as $name => $helper) {
				if (is_string($helper) && !is_string($name)) {
					$provider = $builder->addDefinition($this->prefix('helperProvider.' . $config->getUniqueId() . '.' . $name))
						->setClass($helper);

					$latteFactory->addSetup('Flame\Modules\Template\Helper::register($service, ?)', array($provider));

				} else {
					Validators::assert($name, 'string', 'name');
					Validators::assert($helper, 'string|array', 'helper');

					$latteFactory->addSetup('addFilter', array($name, $helper));
				}
			}
		}
	}

	/**
	 * @param IPresenterMappingProvider $extension
	 * @throws Nette\Utils\AssertionException
	 */
	private function setupPresenterMapping(IPresenterMappingProvider $extension)
	{
		$config = new PresenterMappingConfig();
		$extension->setupPresenterMapping($config);
		$mapping = $config->getConfiguration();
		Validators::assert($mapping, 'array', 'mapping');

		if (count($mapping)) {
			$this->getContainerBuilder()->getDefinition('nette.presenterFactory')
				->addSetup('setMapping', array($mapping));
		}
	}

	/**
	 * @param IRouterProvider $extension
	 */
	private function setupRouter(IRouterProvider $extension)
	{
		$builder = $this->getContainerBuilder();
		$router = $builder->getDefinition('router');

		/** @var Nette\DI\CompilerExtension $extension */
		$name = $this->addRouteService($extension->getReflection()->name);
		$router->addSetup('offsetSet', array(NULL, $name));
	}

	/**
	 * @param string $class
	 * @return string
	 */
	private function addRouteService($class)
	{
		$serviceName = md5($class);
		$builder = $this->getContainerBuilder();

		$builder->addDefinition($this->prefix('routeService.' . $serviceName))
			->setClass($class)
			->setInject(TRUE);

		$builder->addDefinition('routerServiceFactory.' . $serviceName)
			->setFactory($this->prefix('@routeService.' . $serviceName) . '::getRoutesDefinition')
			->setAutowired(FALSE);

		return '@routerServiceFactory.' . $serviceName;
	}

	/**
	 * @param IErrorPresenterProvider $extension
	 * @throws Nette\Utils\AssertionException
	 */
	private function setupErrorPresenter(IErrorPresenterProvider $extension)
	{
		$config = new ErrorPresenterConfig();
		$extension->setupErrorPresenter($config);
		$presenterName = $config->getConfiguration();
		Validators::assert($presenterName, 'string', 'presenterName');

		$builder = $this->getContainerBuilder();
		$builder->getDefinition('application')
			->addSetup('$errorPresenter', array($presenterName));
	}

	/**
	 * @return ServiceDefinition
	 */
	private function getLatteFactory()
	{
		$builder = $this->getContainerBuilder();
		return $builder->hasDefinition('nette.latteFactory')
			? $builder->getDefinition('nette.latteFactory')
			: $builder->getDefinition('nette.latte');
	}

	/**
	 * Loads all services tagged as router
	 * and adds them to router service
	 *
	 * @author: Adam Kadlec <adam.kadlec@gmail.com>
	 * @date: 08.10.14
	 */
	private function addRouters()
	{
		$builder = $this->getContainerBuilder();

		// Get application router
		$router = $builder->getDefinition('router');

		// Init collections
		$routerFactories = array();

		foreach ($builder->findByTag(self::TAG_ROUTER) as $serviceName => $priority) {
			// Priority is not defined...
			if (is_bool($priority)) {
				// ...use default value
				$priority = 100;
			}

			$routerFactories[$priority][$serviceName] = $serviceName;
		}

		// Sort routes by priority
		if (!empty($routerFactories)) {
			krsort($routerFactories, SORT_NUMERIC);

			foreach ($routerFactories as $priority => $items) {
				$routerFactories[$priority] = $items;
			}

			// Process all routes services by priority...
			foreach ($routerFactories as $priority => $items) {
				// ...and by service name...
				foreach($items as $serviceName) {
					$factory = new Nette\DI\Statement(array('@' . $serviceName, 'createRouter'));
					$router->addSetup('offsetSet', array(NULL, $factory));
				}
			}
		}
	}
}


<?php
/* ===========================================================================
 * Copyright 2013-2016 The Opis Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Config\Drivers;

class PHPFile extends File
{

    /**
     * PHPFile constructor.
     * @param string $path
     * @param string $prefix
     */
    public function __construct(string $path, string $prefix = '')
    {
        parent::__construct($path, $prefix, 'php');
    }

    /**
     * {@inheritdoc}
     */
    protected function readConfig(string $file)
    {
        return include($file);
    }

    /**
     * {@inheritdoc}
     */
    protected function writeConfig(string $file, $config)
    {
        $config = var_export($config, true);
        $config = str_replace('stdClass::__set_state', '(object)', $config);
        $config = "<?php\n\rreturn " . $config . ';';
        $this->fileWrite($file, $config);
    }
}


<?php
/**
 * Part of the Joomla Framework OpenStreetMap Package
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\OpenStreetMap;

/**
 * OpenStreetMap API Info class for the Joomla Framework
 *
 * @since       1.0
 * @deprecated  The joomla/openstreetmap package is deprecated
 */
class Info extends OpenStreetMapObject
{
	/**
	 * Method to get capabilities of the API
	 *
	 * @return	array  The XML response
	 *
	 * @since	1.0
	 */
	public function getCapabilities()
	{
		// Set the API base
		$base = 'capabilities';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'GET', array());

		return simplexml_load_string($response->body);
	}

	/**
	 * Method to retrieve map data of a bounding box
	 *
	 * @param   float  $left    Left boundary
	 * @param   float  $bottom  Bottom boundary
	 * @param   float  $right   Right boundary
	 * @param   float  $top     Top boundary
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function retrieveMapData($left, $bottom, $right, $top)
	{
		// Set the API base
		$base = 'map?bbox=' . $left . ',' . $bottom . ',' . $right . ',' . $top;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'GET', array());

		return simplexml_load_string($response->body);
	}

	/**
	 * Method to retrieve permissions for current user
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function retrievePermissions()
	{
		// Set the API base
		$base = 'permissions';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'GET', array());

		return simplexml_load_string($response->body);
	}
}


<?php
/* ===========================================================================
 * Copyright 2013-2016 The Opis Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Config\Drivers;

use RuntimeException;
use Opis\Config\ConfigHelper;
use Opis\Config\ConfigInterface;

class File implements ConfigInterface
{
    /** @var string */
    protected $path;

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

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

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

    /**
     * File constructor.
     * @param string $path
     * @param string $prefix
     * @param string $extension
     */
    public function __construct(string $path, string $prefix = '', string $extension = 'conf')
    {
        $this->path = rtrim($path, '/');
        $this->prefix = trim($prefix, '.');
        $this->extension = trim($extension, '.');

        if ($this->prefix !== '') {
            $this->prefix .= '.';
        }

        if ($this->extension !== '') {
            $this->extension = '.' . $this->extension;
        }

        if (!is_dir($this->path) && !@mkdir($this->path, 0775, true)) {
            throw new RuntimeException(vsprintf("Config directory ('%s') does not exist.", [$this->path]));
        }

        if (!is_writable($this->path) || !is_readable($this->path)) {
            throw new RuntimeException(vsprintf("Config directory ('%s') is not writable or readable.", [$this->path]));
        }

    }

    /**
     * @param string $key
     * @return string
     */
    protected function configFile(string $key) : string
    {
        return $this->path . '/' . $this->prefix . $key . $this->extension;
    }

    /**
     * @param string $file
     * @param string $data
     */
    protected function fileWrite(string &$file, string &$data)
    {
        $chmod = !file_exists($file);
        $fh = fopen($file, 'c');
        flock($fh, LOCK_EX);
        if ($chmod) {
            chmod($file, 0774);
        }
        ftruncate($fh, 0);
        fwrite($fh, $data);
        flock($fh, LOCK_UN);
        fclose($fh);
    }

    /**
     * @param string $file
     * @return mixed
     */
    protected function readConfig(string $file)
    {
        return unserialize(file_get_contents($file));
    }

    /**
     * @param string $file
     * @param array|object $config
     */
    protected function writeConfig(string $file, $config)
    {
        $config = serialize($config);
        $this->fileWrite($file, $config);
    }

    /**
     * {@inheritdoc}
     */
    public function write(string $name, $value) : bool
    {
        $path = explode('.', $name);
        $key = $path[0];
        $file = $this->configFile($key);

        if (!isset($this->cache[$key])) {
            if (file_exists($file)) {
                $this->cache[$key] = new ConfigHelper($this->readConfig($file));
            } else {
                $this->cache[$key] = new ConfigHelper();
            }

        }

        $this->cache[$key]->set($path, $value);
        $this->writeConfig($file, $this->cache[$key]->getConfig());
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function read(string $name, $default = null)
    {
        $path = explode('.', $name);
        $key = $path[0];

        if (!isset($this->cache[$key])) {
            $file = $this->configFile($key);

            if (!file_exists($file)) {
                return $default;
            }

            $this->cache[$key] = new ConfigHelper($this->readConfig($file));

        }

        return $this->cache[$key]->get($path, $default);
    }

    /**
     * {@inheritdoc}
     */
    public function has(string $name) : bool
    {
        $path = explode('.', $name);
        $key = $path[0];

        if (!isset($this->cache[$key])) {
            $file = $this->configFile($key);

            if (!file_exists($file)) {
                return false;
            }

            $this->cache[$key] = new ConfigHelper($this->readConfig($file));
        }

        return $this->cache[$key]->has($path);
    }

    /**
     * {@inheritdoc}
     */
    public function delete(string $name) : bool
    {
        $path = explode('.', $name);
        $key = $path[0];
        $file = $this->configFile($key);

        if (count($path) === 1) {
            if (file_exists($file)) {
                if (unlink($file)) {
                    unset($this->cache[$key]);
                    return true;
                }

                return false;
            }

            return false;
        }

        if (!isset($this->cache[$key])) {
            if (!file_exists($file)) {
                return false;
            }

            $this->cache[$key] = new ConfigHelper($this->readConfig($file));
        }

        if ($this->cache[$key]->delete($path)) {
            $this->writeConfig($file, $this->cache[$key]->getConfig());
            return true;
        }

        return false;
    }

}


<?php

/*
 * This file is part of the FOSCKEditor Bundle.
 *
 * (c) 2018 - present  Friends of Symfony
 * (c) 2009 - 2017     Eric GELOEN <geloen.eric@gmail.com>
 * (c) 2018 - Al Ganiev <helios.ag@gmail.com>
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 * Adapted for Summernote by Al Ganiev <helios.ag@gmail.com>
 */

namespace FM\SummernoteBundle\Installer;

use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 * @author GeLo <geloen.eric@gmail.com>
 */
class SummernoteInstaller
{
    const CLEAR_DROP = 'drop';

    const CLEAR_KEEP = 'keep';

    const CLEAR_SKIP = 'skip';

    const NOTIFY_CLEAR = 'clear';

    const NOTIFY_CLEAR_ARCHIVE = 'clear-archive';

    const NOTIFY_CLEAR_COMPLETE = 'clear-complete';

    const NOTIFY_CLEAR_PROGRESS = 'clear-progress';

    const NOTIFY_CLEAR_QUESTION = 'clear-question';

    const NOTIFY_CLEAR_SIZE = 'clear-size';

    const NOTIFY_DOWNLOAD = 'download';

    const NOTIFY_DOWNLOAD_COMPLETE = 'download-complete';

    const NOTIFY_DOWNLOAD_PROGRESS = 'download-progress';

    const NOTIFY_DOWNLOAD_SIZE = 'download-size';

    const NOTIFY_EXTRACT = 'extract';

    const NOTIFY_EXTRACT_COMPLETE = 'extract-complete';

    const NOTIFY_EXTRACT_PROGRESS = 'extract-progress';

    const NOTIFY_EXTRACT_SIZE = 'extract-size';

    /**
     * @var string
     */
    private static $archive = 'https://https://github.com/summernote/summernote/archive/%s.zip';

    /**
     * @var OptionsResolver
     */
    private $resolver;

    /**
     * @param mixed[] $options
     */
    public function __construct(array $options = [])
    {
        $this->resolver = (new OptionsResolver())
            ->setDefaults(array_merge([
                'clear'    => null,
                'notifier' => null,
                'path'     => dirname(__DIR__).'/Resources/public',
                'version'  => self::VERSION_LATEST,
            ], $options))
            ->setAllowedTypes('excludes', 'array')
            ->setAllowedTypes('notifier', ['null', 'callable'])
            ->setAllowedTypes('path', 'string')
            ->setAllowedTypes('version', 'string')
            ->setAllowedValues('clear', [self::CLEAR_DROP, self::CLEAR_KEEP, self::CLEAR_SKIP, null])
            ->setNormalizer('path', function (Options $options, $path) {
                return rtrim($path, '/');
            });
    }

    /**
     * @param mixed[] $options
     *
     * @return bool
     */
    public function install(array $options = [])
    {
        $options = $this->resolver->resolve($options);

        if (self::CLEAR_SKIP === $this->clear($options)) {
            return false;
        }

        $this->extract($this->download($options), $options);

        return true;
    }

    /**
     * @param mixed[] $options
     *
     * @return int
     */
    private function clear(array $options)
    {
        if (!file_exists($options['path'].'/summernote.js')) {
            return self::CLEAR_DROP;
        }

        if (null === $options['clear'] && null !== $options['notifier']) {
            $options['clear'] = $this->notify($options['notifier'], self::NOTIFY_CLEAR, $options['path']);
        }

        if (null === $options['clear']) {
            $options['clear'] = self::CLEAR_SKIP;
        }

        if (self::CLEAR_DROP === $options['clear']) {
            $files = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($options['path'], \RecursiveDirectoryIterator::SKIP_DOTS),
                \RecursiveIteratorIterator::CHILD_FIRST
            );

            $this->notify($options['notifier'], self::NOTIFY_CLEAR_SIZE, iterator_count($files));

            foreach ($files as $file) {
                $filePath = $file->getRealPath();
                $this->notify($options['notifier'], self::NOTIFY_CLEAR_PROGRESS, $filePath);

                if ($dir = $file->isDir()) {
                    $success = @rmdir($filePath);
                } else {
                    $success = @unlink($filePath);
                }

                if (!$success) {
                    throw $this->createException(sprintf(
                        'Unable to remove the %s "%s".',
                        $dir ? 'directory' : 'file',
                        $filePath
                    ));
                }
            }

            $this->notify($options['notifier'], self::NOTIFY_CLEAR_COMPLETE);
        }

        return $options['clear'];
    }

    /**
     * @param mixed[] $options
     *
     * @return string
     */
    private function download(array $options)
    {
        $url = sprintf(self::$archive, $options['version']);
        $this->notify($options['notifier'], self::NOTIFY_DOWNLOAD, $url);

        $zip = @file_get_contents($url, false, $this->createStreamContext($options['notifier']));

        if (false === $zip) {
            throw $this->createException(sprintf('Unable to download Summernote ZIP archive from "%s".', $url));
        }

        $path = tempnam(sys_get_temp_dir(), 'summernote-'.$options['version'].'.zip');

        if (!@file_put_contents($path, $zip)) {
            throw $this->createException(sprintf('Unable to write Summernote ZIP archive to "%s".', $path));
        }

        $this->notify($options['notifier'], self::NOTIFY_DOWNLOAD_COMPLETE, $path);

        return $path;
    }

    /**
     * @param callable|null $notifier
     *
     * @return resource
     */
    private function createStreamContext(callable $notifier = null)
    {
        $context = [];
        $proxy   = getenv('https_proxy') ?: getenv('http_proxy');

        if ($proxy) {
            $context['proxy']           = $proxy;
            $context['request_fulluri'] = (bool) getenv('https_proxy_request_fulluri') ?:
                getenv('http_proxy_request_fulluri');
        }

        return stream_context_create($context, [
            'notification' => function (
                $code,
                $severity,
                $message,
                $messageCode,
                $transferred,
                $size
            ) use ($notifier) {
                if (null === $notifier) {
                    return;
                }

                switch ($code) {
                    case STREAM_NOTIFY_FILE_SIZE_IS:
                        $this->notify($notifier, self::NOTIFY_DOWNLOAD_SIZE, $size);

                        break;

                    case STREAM_NOTIFY_PROGRESS:
                        $this->notify($notifier, self::NOTIFY_DOWNLOAD_PROGRESS, $transferred);

                        break;
                }
            },
        ]);
    }

    /**
     * @param string  $path
     * @param mixed[] $options
     */
    private function extract($path, array $options)
    {
        $this->notify($options['notifier'], self::NOTIFY_EXTRACT, $options['path']);

        $zip = new \ZipArchive();
        $zip->open($path);

        $this->notify($options['notifier'], self::NOTIFY_EXTRACT_SIZE, $zip->numFiles);

        $offset = 20 + strlen($options['release']) + strlen($options['version']);

        for ($i = 0; $i < $zip->numFiles; ++$i) {
            $this->extractFile(
                $file = $zip->getNameIndex($i),
                substr($file, $offset),
                $path,
                $options
            );
        }

        $zip->close();

        $this->notify($options['notifier'], self::NOTIFY_EXTRACT_COMPLETE);
        $this->notify($options['notifier'], self::NOTIFY_CLEAR_ARCHIVE, $path);

        if (!@unlink($path)) {
            throw $this->createException(sprintf('Unable to remove the Summernote ZIP archive "%s".', $path));
        }
    }

    /**
     * @param string  $file
     * @param string  $rewrite
     * @param string  $origin
     * @param mixed[] $options
     */
    private function extractFile($file, $rewrite, $origin, array $options)
    {
        $this->notify($options['notifier'], self::NOTIFY_EXTRACT_PROGRESS, $rewrite);

        $from = 'zip://'.$origin.'#'.$file;
        $to   = $options['path'].'/'.$rewrite;

        foreach ($options['excludes'] as $exclude) {
            if (0 === strpos($rewrite, $exclude)) {
                return;
            }
        }

        if ('/' === substr($from, -1)) {
            if (!is_dir($to) && !@mkdir($to)) {
                throw $this->createException(sprintf('Unable to create the directory "%s".', $to));
            }

            return;
        }

        if (!@copy($from, $to)) {
            throw $this->createException(sprintf('Unable to extract the file "%s" to "%s".', $file, $to));
        }
    }

    /**
     * @param callable|null $notifier
     * @param string        $type
     * @param mixed         $data
     *
     * @return mixed
     */
    private function notify(callable $notifier = null, $type, $data = null)
    {
        if (null !== $notifier) {
            return $notifier($type, $data);
        }
    }

    /**
     * @param string $message
     *
     * @return \RuntimeException
     */
    private function createException($message)
    {
        $error = error_get_last();

        if (isset($error['message'])) {
            $message .= sprintf(' (%s)', $error['message']);
        }

        return new \RuntimeException($message);
    }
}


<?php
/**
 * Part of the Joomla Framework OpenStreetMap Package
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\OpenStreetMap;

/**
 * OpenStreetMap API Elements class for the Joomla Framework
 *
 * @since       1.0
 * @deprecated  The joomla/openstreetmap package is deprecated
 */
class Elements extends OpenStreetMapObject
{
	/**
	 * Method to create a node
	 *
	 * @param   integer  $changeset  Changeset id
	 * @param   float    $latitude   Latitude of the node
	 * @param   float    $longitude  Longitude of the node
	 * @param   arary    $tags       Array of tags for a node
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function createNode($changeset, $latitude, $longitude, $tags)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'node/create';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$tagList = '';

		// Create XML node
		if (!empty($tags))
		{
			foreach ($tags as $key => $value)
			{
				$tagList .= '<tag k="' . $key . '" v="' . $value . '"/>';
			}
		}

		$xml = '<?xml version="1.0" encoding="UTF-8"?>
				<osm version="0.6" generator="JoomlaOpenStreetMap">
				<node changeset="' . $changeset . '" lat="' . $latitude . '" lon="' . $longitude . '">'
				. $tagList .
				'</node>
				</osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		return $response->body;
	}

	/**
	 * Method to create a way
	 *
	 * @param   integer  $changeset  Changeset id
	 * @param   array    $tags       Array of tags for a way
	 * @param   array    $nds        Node ids to refer
	 *
	 * @return  array   The XML response
	 *
	 * @since   1.0
	 */
	public function createWay($changeset, $tags, $nds)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'way/create';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$tagList = '';

		// Create XML node
		if (!empty($tags))
		{
			foreach ($tags as $key => $value)
			{
				$tagList .= '<tag k="' . $key . '" v="' . $value . '"/>';
			}
		}

		$ndList = '';

		if (!empty($nds))
		{
			foreach ($nds as $value)
			{
				$ndList .= '<nd ref="' . $value . '"/>';
			}
		}

		$xml = '<?xml version="1.0" encoding="UTF-8"?>
				<osm version="0.6" generator="JoomlaOpenStreetMap">
				<way changeset="' . $changeset . '">'
					. $tagList
					. $ndList .
				'</way>
			</osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		return $response->body;
	}

	/**
	 * Method to create a relation
	 *
	 * @param   integer  $changeset  Changeset id
	 * @param   array    $tags       Array of tags for a relation
	 * @param   array    $members    Array of members for a relation
	 *                               eg: $members = array(array("type"=>"node", "role"=>"stop", "ref"=>"123"), array("type"=>"way", "ref"=>"123"))
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function createRelation($changeset, $tags, $members)
	{
		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = 'relation/create';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$tagList = '';

		// Create XML node
		if (!empty($tags))
		{
			foreach ($tags as $key => $value)
			{
				$tagList .= '<tag k="' . $key . '" v="' . $value . '"/>';
			}
		}

		// Members
		$memberList = '';

		if (!empty($members))
		{
			foreach ($members as $member)
			{
				if ($member['type'] == 'node')
				{
					$memberList .= '<member type="' . $member['type'] . '" role="' . $member['role'] . '" ref="' . $member['ref'] . '"/>';
				}
				elseif ($member['type'] == 'way')
				{
					$memberList .= '<member type="' . $member['type'] . '" ref="' . $member['ref'] . '"/>';
				}
			}
		}

		$xml = '<?xml version="1.0" encoding="UTF-8"?>
				<osm version="0.6" generator="JoomlaOpenStreetMap">
				<relation relation="' . $changeset . '" >'
					. $tagList
					. $memberList .
				'</relation>
			</osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		return $response->body;
	}

	/**
	 * Method to read an element [node|way|relation]
	 *
	 * @param   string   $element  [node|way|relation]
	 * @param   integer  $id       Element identifier
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function readElement($element, $id)
	{
		if ($element != 'node' && $element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a node, a way or a relation');
		}

		// Set the API base
		$base = $element . '/' . $id;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->$element;
	}

	/**
	 * Method to update an Element [node|way|relation]
	 *
	 * @param   string   $element  [node|way|relation]
	 * @param   string   $xml      Full reperentation of the element with a version number
	 * @param   integer  $id       Element identifier
	 *
	 * @return  array   The xml response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function updateElement($element, $xml, $id)
	{
		if ($element != 'node' && $element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a node, a way or a relation');
		}

		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = $element . '/' . $id;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);

		return $response->body;
	}

	/**
	 * Method to delete an element [node|way|relation]
	 *
	 * @param   string   $element    [node|way|relation]
	 * @param   integer  $id         Element identifier
	 * @param   integer  $version    Element version
	 * @param   integer  $changeset  Changeset identifier
	 * @param   float    $latitude   Latitude of the element
	 * @param   float    $longitude  Longitude of the element
	 *
	 * @return  array   The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function deleteElement($element, $id, $version, $changeset, $latitude = null, $longitude = null)
	{
		if ($element != 'node' && $element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a node, a way or a relation');
		}

		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = $element . '/' . $id;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Create xml
		$xml = '<?xml version="1.0" encoding="UTF-8"?>
				<osm version="0.6" generator="JOpenstreetmap">
				<' . $element . ' id="' . $id . '" version="' . $version . '" changeset="' . $changeset . '"';

		if (!empty($latitude) && !empty($longitude))
		{
			$xml .= ' lat="' . $latitude . '" lon="' . $longitude . '"';
		}

		$xml .= '/></osm>';

		$header['Content-Type'] = 'text/xml';

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'DELETE', $parameters, $xml, $header);

		return $response->body;
	}

	/**
	 * Method to get history of an element [node|way|relation]
	 *
	 * @param   string   $element  [node|way|relation]
	 * @param   integer  $id       Element identifier
	 *
	 * @return  array   The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function historyOfElement($element, $id)
	{
		if ($element != 'node' && $element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a node, a way or a relation');
		}

		// Set the API base
		$base = $element . '/' . $id . '/history';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->$element;
	}

	/**
	 * Method to get details about a version of an element [node|way|relation]
	 *
	 * @param   string   $element  [node|way|relation]
	 * @param   integer  $id       Element identifier
	 * @param   integer  $version  Element version
	 *
	 * @return  array    The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function versionOfElement($element, $id, $version)
	{
		if ($element != 'node' && $element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a node, a way or a relation');
		}

		// Set the API base
		$base = $element . '/' . $id . '/' . $version;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->$element;
	}

	/**
	 * Method to get data about multiple ids of an element [node|way|relation]
	 *
	 * @param   string  $element  [nodes|ways|relations] - use plural word
	 * @param   string  $params   Comma separated list of ids belonging to type $element
	 *
	 * @return  array   The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function multiFetchElements($element, $params)
	{
		if ($element != 'nodes' && $element != 'ways' && $element != 'relations')
		{
			throw new \DomainException('Element should be nodes, ways or relations');
		}

		// Get singular word
		$singleElement = substr($element, 0, \strlen($element) - 1);

		// Set the API base, $params is a string with comma seperated values
		$base = $element . '?' . $element . '=' . $params;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->$singleElement;
	}

	/**
	 * Method to get relations for an Element [node|way|relation]
	 *
	 * @param   string   $element  [node|way|relation]
	 * @param   integer  $id       Element identifier
	 *
	 * @return  array   The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function relationsForElement($element, $id)
	{
		if ($element != 'node' && $element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a node, a way or a relation');
		}

		// Set the API base
		$base = $element . '/' . $id . '/relations';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->$element;
	}

	/**
	 * Method to get ways for a Node element
	 *
	 * @param   integer  $id  Node identifier
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 */
	public function waysForNode($id)
	{
		// Set the API base
		$base = 'node/' . $id . '/ways';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->way;
	}

	/**
	 * Method to get full information about an element [way|relation]
	 *
	 * @param   string   $element  [way|relation]
	 * @param   integer  $id       Identifier
	 *
	 * @return  array  The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function fullElement($element, $id)
	{
		if ($element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a way or a relation');
		}

		// Set the API base
		$base = $element . '/' . $id . '/full';

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$xmlString = $this->sendRequest($path);

		return $xmlString->node;
	}

	/**
	 * Method used by the DWG to hide old versions of elements containing data privacy or copyright infringements
	 *
	 * @param   string   $element      [node|way|relation]
	 * @param   integer  $id           Element identifier
	 * @param   integer  $version      Element version
	 * @param   integer  $redactionId  Redaction id
	 *
	 * @return  array   The xml response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function redaction($element, $id, $version, $redactionId)
	{
		if ($element != 'node' && $element != 'way' && $element != 'relation')
		{
			throw new \DomainException('Element should be a node, a way or a relation');
		}

		$token = $this->oauth->getToken();

		// Set parameters.
		$parameters = array(
			'oauth_token' => $token['key'],
		);

		// Set the API base
		$base = $element . '/' . $id . '/' . $version . '/redact?redaction=' . $redactionId;

		// Build the request path.
		$path = $this->getOption('api.url') . $base;

		// Send the request.
		$response = $this->oauth->oauthRequest($path, 'PUT', $parameters);

		return simplexml_load_string($response->body);
	}
}


<?php
/**
 * Part of the Joomla Framework OpenStreetMap Package
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\OpenStreetMap;

use Joomla\Application\AbstractWebApplication;
use Joomla\Http\Http;
use Joomla\Http\Response;
use Joomla\Input\Input;
use Joomla\OAuth1\Client;

/**
 * Joomla Framework class for generating the OpenStreetMap API access token.
 *
 * @since       1.0
 * @deprecated  The joomla/openstreetmap package is deprecated
 */
class OAuth extends Client
{
	/**
	 * Constructor.
	 *
	 * @param   array                   $options      OAuth options object.
	 * @param   Http                    $client       The HTTP client object.
	 * @param   Input                   $input        The Input object
	 * @param   AbstractWebApplication  $application  The application object.
	 *
	 * @since   1.0
	 */
	public function __construct($options = array(), Http $client, Input $input, AbstractWebApplication $application)
	{
		// Setup the access token URL if not already set.
		if (!isset($options['accessTokenURL']))
		{
			$options['accessTokenURL'] = 'https://www.openstreetmap.org/oauth/access_token';
		}

		// Setup the authorisation URL if not already set.
		if (!isset($options['authoriseURL']))
		{
			$options['authoriseURL'] = 'https://www.openstreetmap.org/oauth/authorize';
		}

		// Setup the request token URL if not already set.
		if (!isset($options['requestTokenURL']))
		{
			$options['requestTokenURL'] = 'https://www.openstreetmap.org/oauth/request_token';
		}

		// Call the OAuth1\Client constructor to setup the object.
		parent::__construct($options, $client, $input, $application, '1.0');
	}

	/**
	 * Method to verify if the access token is valid by making a request to an API endpoint.
	 *
	 * @return  boolean  Returns true if the access token is valid and false otherwise.
	 *
	 * @since   1.0
	 */
	public function verifyCredentials()
	{
		return true;
	}

	/**
	 * Method to validate a response.
	 *
	 * @param   string    $url       The request URL.
	 * @param   Response  $response  The response to validate.
	 *
	 * @return  void
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function validateResponse($url, $response)
	{
		if ($response->code != 200)
		{
			$error = htmlspecialchars($response->body);

			throw new \DomainException($error, $response->code);
		}
	}
}


<?php

namespace Talevskiigor\ComposerBump\Commands;

use Talevskiigor\ComposerBump\Commands\Base\BaseCommand;

class UndoBumpCommand extends BaseCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'bump:undo';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Restore last changes in the compose.json';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $this->error(str_repeat('!!! WARNING !!!',3));
        $this->error('    This will replace content of: composer.json file with content from file: composer.json-backup   !!!');
        if ($this->confirm('Are you suere? [y|N]')) {
            $this->fileHelper->restoreBackupFile();
            $this->info('Restored file: composer.json-backup into file: composer.json');
        }else {
            $this->info('Action was canceled.');
        }

 }

}


<?php

namespace FM\SummernoteBundle\Twig\Extension;

/**
 * Class FMSummernoteExtension.
 */
class FMSummernoteExtension extends \Twig_Extension
{
    /**
     * @var array
     */
    protected $parameters;

    /**
     * @var \Twig_Environment
     */
    protected $twig;

    /**
     * @param $parameters
     * @param \Twig_Environment $twig
     */
    public function __construct($parameters, \Twig_Environment $twig)
    {
        $this->parameters = $parameters;
        $this->twig       = $twig;
    }

    /**
     * @return array
     */
    public function getFunctions()
    {
        return [
            new \Twig_SimpleFunction('summernote_init', [$this, 'summernoteInit'], ['is_safe' => ['html']]),
        ];
    }

    /**
     * @return string
     */
    public function summernoteInit()
    {
        $template = $this->parameters['init_template'];
        $options  = [];

        $options['fontname']            = count($this->parameters['fontname']) > 0 ? $this->prepareArrayParameter('fontname') : $this->getDefaultFontname();
        $options['fontnocheck']         = count($this->parameters['fontnocheck']) > 0 ? $this->prepareArrayParameter('fontnocheck') : null;
        $options['language']            = isset($this->parameters['language']) ? $this->parameters['language'] : null;
        $options['plugins']             = isset($this->parameters['plugins']) ? $this->parameters['plugins'] : null;
        $options['selector']            = $this->parameters['selector'];
        $options['width']               = $this->parameters['width'];
        $options['height']              = $this->parameters['height'];
        $options['include_jquery']      = $this->parameters['include_jquery'];
        $options['include_bootstrap']   = $this->parameters['include_bootstrap'];
        $options['include_fontawesome'] = $this->parameters['include_fontawesome'];
        $options['fontawesome_path']    = $this->parameters['fontawesome_path'];
        $options['bootstrap_css_path']  = $this->parameters['bootstrap_css_path'];
        $options['bootstrap_js_path']   = $this->parameters['bootstrap_js_path'];
        $options['jquery_path']         = $this->parameters['jquery_path'];
        $options['summernote_css_path'] = $this->parameters['summernote_css_path'];
        $options['summernote_js_path']  = $this->parameters['summernote_js_path'];
        $options['jquery_version']      = $this->parameters['jquery_version'];
        $options['toolbar']             = $this->prepareToolbar();

        $base_path = (!isset($this->parameters['base_path']) ? 'bundles/fmsummernote/Jquery'.$options['jquery_version'].'.x/' : $this->parameters['base_path']);

        return $this->twig->render($template, ['sn' => $options, 'base_path' => $base_path]);
    }

    private function prepareToolbar()
    {   // builds summernote toolbar array
        if (empty($this->parameters['toolbar']) && empty($this->parameters['extra_toolbar'])) {
            return;
        }

        $str     = '[';
        $toolbar = $this->parameters['toolbar'];
        $str .= $this->processToolbar($toolbar);
        if (!empty($this->parameters['extra_toolbar'])) {
            if (empty($this->parameters['toolbar'])) {
                $str .= $this->getDefaultToolbar();
            }
            $str .= $this->processToolbar($this->parameters['extra_toolbar']);
        }
        $str .= ']';

        return $str;
    }

    /**
     * Return a javascript array.
     *
     * @var string name
     *             The name of the parameter to look for
     *
     * @return string
     */
    private function prepareArrayParameter($name)
    {
        if (isset($this->parameters[$name])) {
            $parameterArray = $this->parameters[$name];
            $count          = count($parameterArray);
            $str            = "['".$parameterArray[0]."'";

            for ($i = 1; $i < $count; ++$i) {
                $str .= ", '".$parameterArray[$i]."'";
            }

            $str .= ']';

            return $str;
        }
    }

    /**
     * Return [ $key, [data, data] ],.
     *
     * @param array $toolbar
     *
     * @return string
     */
    private function processToolbar(array $toolbar)
    {
        $str = '';
        foreach ($toolbar as $key => $tb) {
            $str .= sprintf("[ '%s', ", $key);
            $str .= json_encode($tb);
            $str .= '], ';
        }

        return $str;
    }

    /**
     * return default toolbar when only extra_toolbar is defined.
     *
     * @return string
     */
    private function getDefaultToolbar()
    {
        return "['style', ['style']],
                ['font', ['bold', 'italic', 'underline', 'clear']],
                ['fontname', ['fontname']],
                ['color', ['color']],
                ['para', ['ul', 'ol', 'paragraph']],
                ['height', ['height']],
                ['table', ['table']],
                ['insert', ['link', 'picture', 'hr']],
                ['view', ['fullscreen', 'codeview']],
                ['help', ['help']],";
    }

    public function getDefaultFontname()
    {
        return "['Arial', 'Courier New', 'Helvetica', 'Times New Roman']";
    }

    /**
     * Returns the name of the extension.
     *
     * @return string The extension name
     */
    public function getName()
    {
        return 'fm_summernote';
    }
}


<?php

namespace Talevskiigor\ComposerBump\Commands;

use Talevskiigor\ComposerBump\Commands\Base\BaseCommand;

class BumpMinorCommand extends BaseCommand
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'bump:minor';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Bump MINOR version (major.MINOR.patch => verison 0.1.0)';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

     $oldVersion = $this->fileHelper->getVersion();

     $newVersion = $this->bumper->bumpMinor($oldVersion)->get();

     $this->fileHelper->setVersion($newVersion)->save();

     $this->info('Bump from: '. $oldVersion.' to ' . $newVersion);
 }

}


<?php
/* ===========================================================================
 * Copyright 2013-2016 The Opis Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Config\Drivers;

class JSON extends File
{
    const DEFAULT_ENCODE_OPTIONS = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;

    /** @var int */
    protected $encodeOptions = 0;

    /**
     * JSON constructor.
     * @param string $path
     * @param string $prefix
     * @param int $encode_options
     */
    public function __construct(string $path, string $prefix = '', int $encode_options = self::DEFAULT_ENCODE_OPTIONS)
    {
        $this->encodeOptions = $encode_options;
        parent::__construct($path, $prefix, 'json');
    }

    /**
     * {@inheritdoc}
     */
    protected function readConfig(string $file)
    {
        return json_decode(file_get_contents($file));
    }

    /**
     * {@inheritdoc}
     */
    protected function writeConfig(string $file, $config)
    {
        $config = json_encode($config, $this->encodeOptions);
        $this->fileWrite($file, $config);
    }
}


<?php
/**
 * Part of the Joomla Framework OpenStreetMap Package
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\OpenStreetMap;

use Joomla\Http\Http;

/**
 * OpenStreetMap API object class for the Joomla Framework
 *
 * @since       1.0
 * @deprecated  The joomla/openstreetmap package is deprecated
 */
abstract class OpenStreetMapObject
{
	/**
	 * Options for the OpenStreetMap object.
	 *
	 * @var    array
	 * @since  1.0
	 */
	protected $options;

	/**
	 * The HTTP client object to use in sending HTTP requests.
	 *
	 * @var    Http
	 * @since  1.0
	 */
	protected $client;

	/**
	 * The OAuth client.
	 *
	 * @var    OAuth
	 * @since  1.0
	 */
	protected $oauth;

	/**
	 * Constructor
	 *
	 * @param   array  $options  OpenStreetMap options object.
	 * @param   Http   $client   The HTTP client object.
	 * @param   OAuth  $oauth    OpenStreetMap OAuth client
	 *
	 * @since   1.0
	 */
	public function __construct($options = array(), Http $client = null, OAuth $oauth = null)
	{
		$this->options = $options;
		$this->client  = isset($client) ? $client : new Http($this->options);
		$this->oauth   = $oauth;
	}

	/**
	 * Get an option from the OpenStreetMapObject instance.
	 *
	 * @param   string  $key  The name of the option to get.
	 *
	 * @return  mixed  The option value.
	 *
	 * @since   1.0
	 */
	public function getOption($key)
	{
		return isset($this->options[$key]) ? $this->options[$key] : null;
	}

	/**
	 * Set an option for the OpenStreetMapObject instance.
	 *
	 * @param   string  $key    The name of the option to set.
	 * @param   mixed   $value  The option value to set.
	 *
	 * @return  OpenStreetMapObject  This object for method chaining.
	 *
	 * @since   1.0
	 */
	public function setOption($key, $value)
	{
		$this->options[$key] = $value;

		return $this;
	}

	/**
	 * Method to send the request which does not require authentication.
	 *
	 * @param   string  $path     The path of the request to make
	 * @param   string  $method   The request method.
	 * @param   array   $headers  The headers passed in the request.
	 * @param   mixed   $data     Either an associative array or a string to be sent with the post request.
	 *
	 * @return  \SimpleXMLElement  The XML response
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	public function sendRequest($path, $method = 'GET', $headers = array(), $data = '')
	{
		// Send the request.
		switch ($method)
		{
			case 'GET':
				$response = $this->client->get($path, $headers);

				break;

			case 'POST':
				$response = $this->client->post($path, $data, $headers);

				break;
		}

		// Validate the response code.
		if ($response->code != 200)
		{
			$error = htmlspecialchars($response->body);

			throw new \DomainException($error, $response->code);
		}

		return simplexml_load_string($response->body);
	}
}


<?php
/**
 * This file is part of the Ray.AuraSqlModule package.
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace Ray\AuraSqlModule;

use Aura\Sql\ConnectionLocatorInterface;
use Ray\AuraSqlModule\Annotation\AuraSql;
use Ray\AuraSqlModule\Annotation\Read;
use Ray\AuraSqlModule\Annotation\ReadOnlyConnection;
use Ray\AuraSqlModule\Annotation\Write;
use Ray\AuraSqlModule\Annotation\WriteConnection;
use Ray\Di\AbstractModule;

class AuraSqlLocatorModule extends AbstractModule
{
    /**
     * @var ConnectionLocatorInterface
     */
    private $connectionLocator;

    /**
     * @var string[]
     */
    private $readMethods;

    /**
     * @var string[]
     */
    private $writeMethods;

    public function __construct(
        ConnectionLocatorInterface $connectionLocator,
        array $readMethods = [],
        array $writeMethods = [],
        AbstractModule $module = null
    ) {
        $this->connectionLocator = $connectionLocator;
        $this->readMethods = $readMethods;
        $this->writeMethods = $writeMethods;
        parent::__construct($module);
    }

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        if ((bool) $this->readMethods && (bool) $this->writeMethods) {
            $this->bind()->annotatedWith(Read::class)->toInstance($this->readMethods);
            $this->bind()->annotatedWith(Write::class)->toInstance($this->writeMethods);
        }
        if ($this->connectionLocator) {
            $this->bind(ConnectionLocatorInterface::class)->toInstance($this->connectionLocator);
        }
        $methods = \array_merge($this->readMethods, $this->writeMethods);
        // @AuraSql
        $this->installLocatorDb($methods);
        // @ReadOnlyConnection @WriteConnection
        $this->installReadWriteConnection();
        // @Transactional
        $this->install(new TransactionalModule);
    }

    protected function installReadWriteConnection()
    {
        // @ReadOnlyConnection
        $this->bindInterceptor(
            $this->matcher->any(),
            $this->matcher->annotatedWith(ReadOnlyConnection::class),
            [AuraSqlSlaveDbInterceptor::class]
        );
        // @WriteConnection
        $this->bindInterceptor(
            $this->matcher->any(),
            $this->matcher->annotatedWith(WriteConnection::class),
            [AuraSqlMasterDbInterceptor::class]
        );
    }

    /**
     * @param string[] $methods
     */
    private function installLocatorDb(array $methods)
    {
        // locator db
        $this->bindInterceptor(
            $this->matcher->annotatedWith(AuraSql::class), // @AuraSql in class
            $this->matcher->logicalAnd(
                new IsInMethodMatcher($methods),
                $this->matcher->logicalNot(
                    $this->matcher->annotatedWith(ReadOnlyConnection::class)
                ),
                $this->matcher->logicalNot(
                    $this->matcher->annotatedWith(Connection::class)
                )
            ),
            [AuraSqlConnectionInterceptor::class]
        );
    }
}


<?php
/*
 * This file is part of the Exchange Rate package, an RunOpenCode project.
 *
 * (c) 2017 RunOpenCode
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace RunOpenCode\ExchangeRate;

use RunOpenCode\ExchangeRate\Contract\ManagerInterface;
use RunOpenCode\ExchangeRate\Contract\ProcessorInterface;
use RunOpenCode\ExchangeRate\Contract\ProcessorsRegistryInterface;
use RunOpenCode\ExchangeRate\Contract\RatesConfigurationRegistryInterface;
use RunOpenCode\ExchangeRate\Contract\RepositoryInterface;
use RunOpenCode\ExchangeRate\Contract\SourceInterface;
use RunOpenCode\ExchangeRate\Contract\SourcesRegistryInterface;
use RunOpenCode\ExchangeRate\Enum\RateType;
use RunOpenCode\ExchangeRate\Exception\ExchangeRateException;
use RunOpenCode\ExchangeRate\Utils\CurrencyCodeUtil;

/**
 * Class Manager
 *
 * Default implementation of manager.
 *
 * @package RunOpenCode\ExchangeRate
 */
class Manager implements ManagerInterface
{
    /**
     * @var string
     */
    protected $baseCurrency;

    /**
     * @var RepositoryInterface
     */
    protected $repository;

    /**
     * @var SourcesRegistryInterface
     */
    protected $sources;

    /**
     * @var ProcessorsRegistryInterface
     */
    protected $processors;

    /**
     * @var RatesConfigurationRegistryInterface
     */
    protected $configurations;

    /**
     * Manager constructor.
     *
     * @param string $baseCurrency
     * @param RepositoryInterface $repository
     * @param SourcesRegistryInterface $sources
     * @param ProcessorsRegistryInterface $processors
     * @param RatesConfigurationRegistryInterface $configurations
     *
     * @throws \RunOpenCode\ExchangeRate\Exception\UnknownCurrencyCodeException
     */
    public function __construct($baseCurrency, RepositoryInterface $repository, SourcesRegistryInterface $sources, ProcessorsRegistryInterface $processors, RatesConfigurationRegistryInterface $configurations)
    {
        $this->baseCurrency = CurrencyCodeUtil::clean($baseCurrency);
        $this->repository = $repository;
        $this->configurations = $configurations;
        $this->sources = $sources;
        $this->processors = $processors;
    }

    /**
     * Get base currency
     *
     * @return string
     */
    public function getBaseCurrency()
    {
        return $this->baseCurrency;
    }

    /**
     * {@inheritdoc}
     *
     * @throws \RunOpenCode\ExchangeRate\Exception\UnknownCurrencyCodeException
     */
    public function has($sourceName, $currencyCode, \DateTime $date = null, $rateType = RateType::MEDIAN)
    {
        return $this->repository->has($sourceName, CurrencyCodeUtil::clean($currencyCode), $date, $rateType);
    }

    /**
     * {@inheritdoc}
     *
     * @throws \RunOpenCode\ExchangeRate\Exception\UnknownCurrencyCodeException
     */
    public function get($sourceName, $currencyCode, \DateTime $date = null, $rateType = RateType::MEDIAN)
    {
        return $this->repository->get($sourceName, CurrencyCodeUtil::clean($currencyCode), $date, $rateType);
    }

    /**
     * {@inheritdoc}
     */
    public function latest($sourceName, $currencyCode, $rateType = RateType::MEDIAN, \DateTimeInterface $date = null)
    {
        return $this->repository->latest($sourceName, CurrencyCodeUtil::clean($currencyCode), $rateType, $date);
    }

    /**
     * {@inheritdoc}
     *
     * @throws \RunOpenCode\ExchangeRate\Exception\UnknownCurrencyCodeException
     */
    public function today($sourceName, $currencyCode, $rateType = RateType::MEDIAN)
    {
        $currencyCode = CurrencyCodeUtil::clean($currencyCode);
        $today = new \DateTime('@'.time());

        if ($this->has($sourceName, $currencyCode, $today, $rateType)) {
            return $this->get($sourceName, $currencyCode, $today, $rateType);
        }

        if ((int) $today->format('N') >= 6 && $this->has($sourceName, $currencyCode, $lastFriday = new \DateTime('last Friday'), $rateType)) {
            return $this->get($sourceName, $currencyCode, $lastFriday, $rateType);
        }

        throw new ExchangeRateException(sprintf('Rate for currency code "%s" of type "%s" from source "%s" is not available for today "%s".', $currencyCode, $rateType, $sourceName, date('Y-m-d')));
    }

    /**
     * {@inheritdoc}
     *
     * @throws \RunOpenCode\ExchangeRate\Exception\UnknownCurrencyCodeException
     */
    public function historical($sourceName, $currencyCode, \DateTime $date, $rateType = RateType::MEDIAN)
    {
        $currencyCode = CurrencyCodeUtil::clean($currencyCode);

        if ($this->has($sourceName, $currencyCode, $date, $rateType)) {
            return $this->get($sourceName, $currencyCode, $date, $rateType);
        }

        if ((int) $date->format('N') === 6 && $this->has($sourceName, $currencyCode, $lastFriday = $date->sub(new \DateInterval('P1D')), $rateType)) {
            return $this->get($sourceName, $currencyCode, $lastFriday, $rateType);
        }

        if ((int) $date->format('N') === 7 && $this->has($sourceName, $currencyCode, $lastFriday = $date->sub(new \DateInterval('P2D')), $rateType)) {
            return $this->get($sourceName, $currencyCode, $lastFriday, $rateType);
        }

        throw new ExchangeRateException(sprintf('Rate for currency code "%s" of type "%s" from source "%s" is not available for historical date "%s".', $currencyCode, $rateType, $sourceName, $date->format('Y-m-d')));
    }

    /**
     * {@inheritdoc}
     */
    public function fetch($sourceName = null, \DateTime $date = null)
    {
        $rates = array();

        $filteredSourceNames = ($sourceName === null) ? array_map(function (SourceInterface $source) {
            return $source->getName();
        }, $this->sources->all()) : (array) $sourceName;

        foreach ($filteredSourceNames as $name) {

            $source = $this->sources->get($name);

            $filteredConfigurations = $this->configurations->all(array(
                'sourceName' => $name,
            ));

            /**
             * @var Configuration $configuration
             */
            foreach ($filteredConfigurations as $configuration) {
                $rates[] = $source->fetch($configuration->getCurrencyCode(), $configuration->getRateType(), $date);
            }
        }

        /**
         * @var ProcessorInterface $processor
         */
        foreach ($this->processors->all() as $processor) {
            $rates = $processor->process($this->baseCurrency, $this->configurations, $rates);
        }

        $this->repository->save($rates);

        return $rates;
    }
}


<?php
/**
 * This file is part of the Ray.AuraSqlModule package.
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace Ray\AuraSqlModule;

use Aura\SqlQuery\Common\DeleteInterface;
use Aura\SqlQuery\Common\InsertInterface;
use Aura\SqlQuery\Common\SelectInterface;
use Aura\SqlQuery\Common\UpdateInterface;
use Ray\AuraSqlModule\Annotation\AuraSqlQueryConfig;
use Ray\Di\AbstractModule;

class AuraSqlQueryModule extends AbstractModule
{
    /**
     * @var string
     */
    private $db;

    public function __construct(string $db, AbstractModule $module = null)
    {
        $this->db = $db;
        parent::__construct($module);
    }

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this->bind()->annotatedWith(AuraSqlQueryConfig::class)->toInstance($this->db);
        $this->bind(SelectInterface::class)->toProvider(AuraSqlQuerySelectProvider::class);
        $this->bind(InsertInterface::class)->toProvider(AuraSqlQueryInsertProvider::class);
        $this->bind(UpdateInterface::class)->toProvider(AuraSqlQueryUpdateProvider::class);
        $this->bind(DeleteInterface::class)->toProvider(AuraSqlQueryDeleteProvider::class);
    }
}


<?php

/*
 * This file is part of the Tika package.
 *
 * (c) Bertrand Zuchuat <bertrand.zuchuat@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Funstaff\Tika;

/**
 * Metadata
 *
 * @author Bertrand Zuchuat <bertrand.zuchuat@gmail.com>
 */
class Metadata implements MetadataInterface
{
    protected $data = array();

    /**
     * Add
     *
     * @param string $name  name of single metadata
     * @param string $value metadata value
     *
     * @return MetadataInterface
     */
    public function add($name, $value)
    {
        $this->data[$name] = $value;

        return $this;
    }

    /**
     * Get
     *
     * @param string $name  name of parameter
     *
     * @return string   metadata value
     */
    public function get($name)
    {
        if (!array_key_exists($name, $this->data)) {
            throw new \InvalidArgumentException(sprintf(
                'The value for "%s" does not exists.',
                $name
            ));
        }

        return $this->data[$name];
    }

    /**
     * Get All
     *
     * @return array    All metadata values
     */
    public function getAll()
    {
        return $this->data;
    }
}


<?php
/**
 * This file is part of the Ray.AuraSqlModule package.
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace Ray\AuraSqlModule\Pagerfanta;

use Aura\Sql\ExtendedPdoInterface;
use Pagerfanta\Exception\LogicException;
use Pagerfanta\Pagerfanta;
use Pagerfanta\View\ViewInterface;
use Ray\AuraSqlModule\Annotation\PagerViewOption;
use Ray\AuraSqlModule\Exception\NotInitialized;

class AuraSqlPager implements AuraSqlPagerInterface
{
    /**
     * @var ViewInterface
     */
    private $view;

    /**
     * @var RouteGeneratorInterface
     */
    private $routeGenerator;

    /**
     * @var array
     */
    private $viewOptions;

    /**
     * @var ExtendedPdoInterface
     */
    private $pdo;

    /**
     * @var string
     */
    private $sql;

    /**
     * @var array
     */
    private $params;

    /**
     * @var int
     */
    private $paging;

    /**
     * @param ViewInterface $view
     * @param array         $viewOptions
     *
     * @PagerViewOption("viewOptions")
     */
    public function __construct(ViewInterface $view, array $viewOptions)
    {
        $this->view = $view;
        $this->viewOptions = $viewOptions;
    }

    /**
     * {@inheritdoc}
     */
    public function init(ExtendedPdoInterface $pdo, $sql, array $params, $paging, RouteGeneratorInterface $routeGenerator)
    {
        $this->pdo = $pdo;
        $this->sql = $sql;
        $this->params = $params;
        $this->paging = $paging;
        $this->routeGenerator = $routeGenerator;
    }

    /**
     * {@inheritdoc}
     */
    public function offsetExists($offset)
    {
        throw new LogicException('unsupported');
    }

    /**
     * {@inheritdoc}
     */
    public function offsetGet($currentPage)
    {
        if (! $this->routeGenerator instanceof RouteGeneratorInterface) {
            throw new NotInitialized();
        }
        $pagerfanta = new Pagerfanta(new ExtendedPdoAdapter($this->pdo, $this->sql, $this->params));
        $pagerfanta->setMaxPerPage($this->paging);
        $pagerfanta->setCurrentPage($currentPage);
        $page = new Page($pagerfanta, $this->routeGenerator, $this->view, $this->viewOptions);
        $page->maxPerPage = $pagerfanta->getMaxPerPage();
        $page->current = $pagerfanta->getCurrentPage();
        $page->hasNext = $pagerfanta->hasNextPage();
        $page->hasPrevious = $pagerfanta->hasPreviousPage();
        $page->data = $pagerfanta->getCurrentPageResults();
        $page->total = $pagerfanta->getNbResults();

        return $page;
    }

    /**
     * {@inheritdoc}
     */
    public function offsetSet($offset, $value)
    {
        throw new LogicException('read only');
    }

    /**
     * {@inheritdoc}
     */
    public function offsetUnset($offset)
    {
        throw new LogicException('read only');
    }
}


<?php
/**
 * @author    Andrew Coulton <andrew@ingenerator.com>
 * @licence   BSD-3-Clause
 */

namespace Ingenerator\BehatTableAssert\TableParser;

use Ingenerator\BehatTableAssert\TableParser\CSV\CSVStreamTableParser;
use Ingenerator\BehatTableAssert\TableParser\CSV\CSVStringTableParser;
use Ingenerator\BehatTableAssert\TableParser\CSV\MinkResponseCSVTableParser;

/**
 * Facade/factory class for creating TableNodes from CSV data using the provided parsers
 *
 * @package Ingenerator\BehatTableAssert\TableParser
 */
class CSVTable
{
    /**
     * Direct construction of this class is not allowed - use the public named constructors to
     * create and parse CSV from the various supported data sources.
     * @internal
     */
    protected function __construct()
    {
    }

    /**
     * Parse CSV from any arbitrary stream resource
     *
     * @param resource $stream
     *
     * @return \Behat\Gherkin\Node\TableNode
     * @throws \InvalidArgumentException
     */
    public static function fromStream($stream)
    {
        return self::newInstance()->makeCSVStreamTableParser()->parse($stream);
    }

    /**
     * Parse CSV from any string
     *
     * @param string $string
     *
     * @return \Behat\Gherkin\Node\TableNode
     * @throws \InvalidArgumentException
     */
    public static function fromString($string)
    {
        return self::newInstance()->makeCSVStringTableParser()->parse($string);
    }

    /**
     * Parse CSV from the HTTP response received by Mink on the most recent request
     *
     * @param \Behat\Mink\Session $session
     *
     * @return \Behat\Gherkin\Node\TableNode
     * @throws \Behat\Mink\Exception\ExpectationException if the Content-Type is not expected
     * @throws \Behat\Mink\Exception\ResponseTextException if the response text looks like HTML
     * @throws \InvalidArgumentException
     */
    public static function fromMinkResponse(\Behat\Mink\Session $session)
    {
        return self::newInstance()->makeMinkResponseCSVTableParser()->parse($session);
    }

    /**
     * @return CSVTable
     */
    protected static function newInstance()
    {
        return new static;
    }

    /**
     * @return \Ingenerator\BehatTableAssert\TableParser\CSV\CSVStreamTableParser
     */
    public function makeCSVStreamTableParser()
    {
        return new CSVStreamTableParser;
    }

    /**
     * @return \Ingenerator\BehatTableAssert\TableParser\CSV\CSVStringTableParser
     */
    public function makeCSVStringTableParser()
    {
        return new CSVStringTableParser(
            $this->makeCSVStreamTableParser()
        );
    }

    /**
     * @return \Ingenerator\BehatTableAssert\TableParser\CSV\MinkResponseCSVTableParser
     */
    public function makeMinkResponseCSVTableParser()
    {
        return new MinkResponseCSVTableParser(
            $this->makeCSVStringTableParser()
        );
    }
}