This commit is contained in:
fzorb 2025-01-10 19:54:37 +02:00
parent 93bc137400
commit e7a38528e4
2076 changed files with 0 additions and 220001 deletions

25
vendor/autoload.php vendored
View File

@ -1,25 +0,0 @@
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit39e76b5f4d8c6722589be79886dc5716::getLoader();

119
vendor/bin/carbon vendored
View File

@ -1,119 +0,0 @@
#!/usr/bin/env php
<?php
/**
* Proxy PHP file generated by Composer
*
* This file includes the referenced bin path (../nesbot/carbon/bin/carbon)
* using a stream wrapper to prevent the shebang from being output on PHP<8
*
* @generated
*/
namespace Composer;
$GLOBALS['_composer_bin_dir'] = __DIR__;
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
if (PHP_VERSION_ID < 80000) {
if (!class_exists('Composer\BinProxyWrapper')) {
/**
* @internal
*/
final class BinProxyWrapper
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 17);
$this->realpath = realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = fopen($this->realpath, $mode);
$this->position = 0;
return (bool) $this->handle;
}
public function stream_read($count)
{
$data = fread($this->handle, $count);
if ($this->position === 0) {
$data = preg_replace('{^#!.*\r?\n}', '', $data);
}
$this->position += strlen($data);
return $data;
}
public function stream_cast($castAs)
{
return $this->handle;
}
public function stream_close()
{
fclose($this->handle);
}
public function stream_lock($operation)
{
return $operation ? flock($this->handle, $operation) : true;
}
public function stream_seek($offset, $whence)
{
if (0 === fseek($this->handle, $offset, $whence)) {
$this->position = ftell($this->handle);
return true;
}
return false;
}
public function stream_tell()
{
return $this->position;
}
public function stream_eof()
{
return feof($this->handle);
}
public function stream_stat()
{
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return true;
}
public function url_stat($path, $flags)
{
$path = substr($path, 17);
if (file_exists($path)) {
return stat($path);
}
return false;
}
}
}
if (
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
return include("phpvfscomposer://" . __DIR__ . '/..'.'/nesbot/carbon/bin/carbon');
}
}
return include __DIR__ . '/..'.'/nesbot/carbon/bin/carbon';

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2023 Carbon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,14 +0,0 @@
# carbonphp/carbon-doctrine-types
Types to use Carbon in Doctrine
## Documentation
[Check how to use in the official Carbon documentation](https://carbon.nesbot.com/symfony/)
This package is an externalization of [src/Carbon/Doctrine](https://github.com/briannesbitt/Carbon/tree/2.71.0/src/Carbon/Doctrine)
from `nestbot/carbon` package.
Externalization allows to better deal with different versions of dbal. With
version 4.0 of dbal, it no longer sustainable to be compatible with all version
using a single code.

View File

@ -1,36 +0,0 @@
{
"name": "carbonphp/carbon-doctrine-types",
"description": "Types to use Carbon in Doctrine",
"type": "library",
"keywords": [
"date",
"time",
"DateTime",
"Carbon",
"Doctrine"
],
"require": {
"php": "^8.1"
},
"require-dev": {
"doctrine/dbal": "^4.0.0",
"nesbot/carbon": "^2.71.0 || ^3.0.0",
"phpunit/phpunit": "^10.3"
},
"conflict": {
"doctrine/dbal": "<4.0.0 || >=5.0.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Carbon\\Doctrine\\": "src/Carbon/Doctrine/"
}
},
"authors": [
{
"name": "KyleKatarn",
"email": "kylekatarnls@gmail.com"
}
],
"minimum-stability": "dev"
}

View File

@ -1,16 +0,0 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
use Doctrine\DBAL\Platforms\AbstractPlatform;
interface CarbonDoctrineType
{
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform);
public function convertToPHPValue(mixed $value, AbstractPlatform $platform);
public function convertToDatabaseValue($value, AbstractPlatform $platform);
}

View File

@ -1,9 +0,0 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrineType
{
}

View File

@ -1,9 +0,0 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
class CarbonType extends DateTimeType implements CarbonDoctrineType
{
}

View File

@ -1,131 +0,0 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
use Carbon\Carbon;
use Carbon\CarbonInterface;
use DateTimeInterface;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Types\Exception\InvalidType;
use Doctrine\DBAL\Types\Exception\ValueNotConvertible;
use Exception;
/**
* @template T of CarbonInterface
*/
trait CarbonTypeConverter
{
/**
* This property differentiates types installed by carbonphp/carbon-doctrine-types
* from the ones embedded previously in nesbot/carbon source directly.
*
* @readonly
*/
public bool $external = true;
/**
* @return class-string<T>
*/
protected function getCarbonClassName(): string
{
return Carbon::class;
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
{
$precision = min(
$fieldDeclaration['precision'] ?? DateTimeDefaultPrecision::get(),
$this->getMaximumPrecision($platform),
);
$type = parent::getSQLDeclaration($fieldDeclaration, $platform);
if (!$precision) {
return $type;
}
if (str_contains($type, '(')) {
return preg_replace('/\(\d+\)/', "($precision)", $type);
}
[$before, $after] = explode(' ', "$type ");
return trim("$before($precision) $after");
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if ($value === null) {
return $value;
}
if ($value instanceof DateTimeInterface) {
return $value->format('Y-m-d H:i:s.u');
}
throw InvalidType::new(
$value,
static::class,
['null', 'DateTime', 'Carbon']
);
}
private function doConvertToPHPValue(mixed $value)
{
$class = $this->getCarbonClassName();
if ($value === null || is_a($value, $class)) {
return $value;
}
if ($value instanceof DateTimeInterface) {
return $class::instance($value);
}
$date = null;
$error = null;
try {
$date = $class::parse($value);
} catch (Exception $exception) {
$error = $exception;
}
if (!$date) {
throw ValueNotConvertible::new(
$value,
static::class,
'Y-m-d H:i:s.u or any format supported by '.$class.'::parse()',
$error
);
}
return $date;
}
private function getMaximumPrecision(AbstractPlatform $platform): int
{
if ($platform instanceof DB2Platform) {
return 12;
}
if ($platform instanceof OraclePlatform) {
return 9;
}
if ($platform instanceof SQLServerPlatform || $platform instanceof SQLitePlatform) {
return 3;
}
return 6;
}
}

View File

@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
class DateTimeDefaultPrecision
{
private static $precision = 6;
/**
* Change the default Doctrine datetime and datetime_immutable precision.
*
* @param int $precision
*/
public static function set(int $precision): void
{
self::$precision = $precision;
}
/**
* Get the default Doctrine datetime and datetime_immutable precision.
*
* @return int
*/
public static function get(): int
{
return self::$precision;
}
}

View File

@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
use Carbon\CarbonImmutable;
use DateTimeImmutable;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\VarDateTimeImmutableType;
class DateTimeImmutableType extends VarDateTimeImmutableType implements CarbonDoctrineType
{
/** @use CarbonTypeConverter<CarbonImmutable> */
use CarbonTypeConverter;
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?CarbonImmutable
{
return $this->doConvertToPHPValue($value);
}
/**
* @return class-string<CarbonImmutable>
*/
protected function getCarbonClassName(): string
{
return CarbonImmutable::class;
}
}

View File

@ -1,24 +0,0 @@
<?php
declare(strict_types=1);
namespace Carbon\Doctrine;
use Carbon\Carbon;
use DateTime;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\VarDateTimeType;
class DateTimeType extends VarDateTimeType implements CarbonDoctrineType
{
/** @use CarbonTypeConverter<Carbon> */
use CarbonTypeConverter;
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Carbon
{
return $this->doConvertToPHPValue($value);
}
}

View File

@ -1,579 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var string|null */
private $apcuPrefix;
/**
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return list<string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array<string, string> $classMap Class to filename map
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
$paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
$paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders keyed by their corresponding vendor directories.
*
* @return array<string, self>
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View File

@ -1,359 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*
* @final
*/
class InstalledVersions
{
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool|null
*/
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static $installedByVendor = array();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
*/
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}
}

View File

@ -1,21 +0,0 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,21 +0,0 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'DateError' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateError.php',
'DateException' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateException.php',
'DateInvalidOperationException' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateInvalidOperationException.php',
'DateInvalidTimeZoneException' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateInvalidTimeZoneException.php',
'DateMalformedIntervalStringException' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateMalformedIntervalStringException.php',
'DateMalformedPeriodStringException' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateMalformedPeriodStringException.php',
'DateMalformedStringException' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateMalformedStringException.php',
'DateObjectError' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateObjectError.php',
'DateRangeError' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/DateRangeError.php',
'Override' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/Override.php',
'SQLite3Exception' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/SQLite3Exception.php',
);

View File

@ -1,20 +0,0 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'662a729f963d39afe703c9d9b7ab4a8c' => $vendorDir . '/symfony/polyfill-php83/bootstrap.php',
'2203a247e6fda86070a5e4e07aed533a' => $vendorDir . '/symfony/clock/Resources/now.php',
'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php',
'3be16222a6efa6dd226a219eaaff823b' => $vendorDir . '/ratchet/pawl/src/functions_include.php',
'c4e03ecd470d2a87804979c0a8152284' => $vendorDir . '/react/async/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'864b292aadc96fda0e2642b894a38d16' => $vendorDir . '/team-reflex/discord-php/src/Discord/functions.php',
);

View File

@ -1,10 +0,0 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'TrafficCophp' => array($vendorDir . '/trafficcophp/bytebuffer/src'),
);

View File

@ -1,45 +0,0 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Tests\\Discord\\Http\\' => array($vendorDir . '/discord-php/http/tests/Discord'),
'Symfony\\Polyfill\\Php83\\' => array($vendorDir . '/symfony/polyfill-php83'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Contracts\\Translation\\' => array($vendorDir . '/symfony/translation-contracts'),
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'),
'Symfony\\Component\\Clock\\' => array($vendorDir . '/symfony/clock'),
'React\\Stream\\' => array($vendorDir . '/react/stream/src'),
'React\\Socket\\' => array($vendorDir . '/react/socket/src'),
'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
'React\\Http\\' => array($vendorDir . '/react/http/src'),
'React\\EventLoop\\' => array($vendorDir . '/react/event-loop/src'),
'React\\Dns\\' => array($vendorDir . '/react/dns/src'),
'React\\Datagram\\' => array($vendorDir . '/react/datagram/src'),
'React\\ChildProcess\\' => array($vendorDir . '/react/child-process/src'),
'React\\Cache\\' => array($vendorDir . '/react/cache/src'),
'React\\Async\\' => array($vendorDir . '/react/async/src'),
'Ratchet\\RFC6455\\' => array($vendorDir . '/ratchet/rfc6455/src'),
'Ratchet\\Client\\' => array($vendorDir . '/ratchet/pawl/src'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Fig\\Http\\Message\\' => array($vendorDir . '/fig/http-message-util/src'),
'Evenement\\' => array($vendorDir . '/evenement/evenement/src'),
'Discord\\Http\\' => array($vendorDir . '/discord-php/http/src/Discord'),
'Discord\\' => array($vendorDir . '/discord/interactions/discord', $vendorDir . '/team-reflex/discord-php/src/Discord'),
'DantSu\\PHPImageEditor\\' => array($vendorDir . '/dantsu/php-image-editor/src'),
'DantSu\\OpenStreetMapStaticAPI\\' => array($vendorDir . '/dantsu/php-osm-static-api/src'),
'Carbon\\Doctrine\\' => array($vendorDir . '/carbonphp/carbon-doctrine-types/src/Carbon/Doctrine'),
'Carbon\\' => array($vendorDir . '/nesbot/carbon/src/Carbon'),
);

View File

@ -1,50 +0,0 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit39e76b5f4d8c6722589be79886dc5716
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit39e76b5f4d8c6722589be79886dc5716', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit39e76b5f4d8c6722589be79886dc5716', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit39e76b5f4d8c6722589be79886dc5716::getInitializer($loader));
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit39e76b5f4d8c6722589be79886dc5716::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}
return $loader;
}
}

View File

@ -1,276 +0,0 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit39e76b5f4d8c6722589be79886dc5716
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'662a729f963d39afe703c9d9b7ab4a8c' => __DIR__ . '/..' . '/symfony/polyfill-php83/bootstrap.php',
'2203a247e6fda86070a5e4e07aed533a' => __DIR__ . '/..' . '/symfony/clock/Resources/now.php',
'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php',
'3be16222a6efa6dd226a219eaaff823b' => __DIR__ . '/..' . '/ratchet/pawl/src/functions_include.php',
'c4e03ecd470d2a87804979c0a8152284' => __DIR__ . '/..' . '/react/async/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'864b292aadc96fda0e2642b894a38d16' => __DIR__ . '/..' . '/team-reflex/discord-php/src/Discord/functions.php',
);
public static $prefixLengthsPsr4 = array (
'T' =>
array (
'Tests\\Discord\\Http\\' => 19,
),
'S' =>
array (
'Symfony\\Polyfill\\Php83\\' => 23,
'Symfony\\Polyfill\\Mbstring\\' => 26,
'Symfony\\Contracts\\Translation\\' => 30,
'Symfony\\Component\\Translation\\' => 30,
'Symfony\\Component\\OptionsResolver\\' => 34,
'Symfony\\Component\\Clock\\' => 24,
),
'R' =>
array (
'React\\Stream\\' => 13,
'React\\Socket\\' => 13,
'React\\Promise\\' => 14,
'React\\Http\\' => 11,
'React\\EventLoop\\' => 16,
'React\\Dns\\' => 10,
'React\\Datagram\\' => 15,
'React\\ChildProcess\\' => 19,
'React\\Cache\\' => 12,
'React\\Async\\' => 12,
'Ratchet\\RFC6455\\' => 16,
'Ratchet\\Client\\' => 15,
),
'P' =>
array (
'Psr\\SimpleCache\\' => 16,
'Psr\\Log\\' => 8,
'Psr\\Http\\Message\\' => 17,
'Psr\\Http\\Client\\' => 16,
'Psr\\Clock\\' => 10,
),
'M' =>
array (
'Monolog\\' => 8,
),
'G' =>
array (
'GuzzleHttp\\Psr7\\' => 16,
'GuzzleHttp\\Promise\\' => 19,
'GuzzleHttp\\' => 11,
),
'F' =>
array (
'Fig\\Http\\Message\\' => 17,
),
'E' =>
array (
'Evenement\\' => 10,
),
'D' =>
array (
'Discord\\Http\\' => 13,
'Discord\\' => 8,
'DantSu\\PHPImageEditor\\' => 22,
'DantSu\\OpenStreetMapStaticAPI\\' => 30,
),
'C' =>
array (
'Carbon\\Doctrine\\' => 16,
'Carbon\\' => 7,
),
);
public static $prefixDirsPsr4 = array (
'Tests\\Discord\\Http\\' =>
array (
0 => __DIR__ . '/..' . '/discord-php/http/tests/Discord',
),
'Symfony\\Polyfill\\Php83\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-php83',
),
'Symfony\\Polyfill\\Mbstring\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
),
'Symfony\\Contracts\\Translation\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/translation-contracts',
),
'Symfony\\Component\\Translation\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/translation',
),
'Symfony\\Component\\OptionsResolver\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/options-resolver',
),
'Symfony\\Component\\Clock\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/clock',
),
'React\\Stream\\' =>
array (
0 => __DIR__ . '/..' . '/react/stream/src',
),
'React\\Socket\\' =>
array (
0 => __DIR__ . '/..' . '/react/socket/src',
),
'React\\Promise\\' =>
array (
0 => __DIR__ . '/..' . '/react/promise/src',
),
'React\\Http\\' =>
array (
0 => __DIR__ . '/..' . '/react/http/src',
),
'React\\EventLoop\\' =>
array (
0 => __DIR__ . '/..' . '/react/event-loop/src',
),
'React\\Dns\\' =>
array (
0 => __DIR__ . '/..' . '/react/dns/src',
),
'React\\Datagram\\' =>
array (
0 => __DIR__ . '/..' . '/react/datagram/src',
),
'React\\ChildProcess\\' =>
array (
0 => __DIR__ . '/..' . '/react/child-process/src',
),
'React\\Cache\\' =>
array (
0 => __DIR__ . '/..' . '/react/cache/src',
),
'React\\Async\\' =>
array (
0 => __DIR__ . '/..' . '/react/async/src',
),
'Ratchet\\RFC6455\\' =>
array (
0 => __DIR__ . '/..' . '/ratchet/rfc6455/src',
),
'Ratchet\\Client\\' =>
array (
0 => __DIR__ . '/..' . '/ratchet/pawl/src',
),
'Psr\\SimpleCache\\' =>
array (
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
),
'Psr\\Log\\' =>
array (
0 => __DIR__ . '/..' . '/psr/log/src',
),
'Psr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-message/src',
1 => __DIR__ . '/..' . '/psr/http-factory/src',
),
'Psr\\Http\\Client\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-client/src',
),
'Psr\\Clock\\' =>
array (
0 => __DIR__ . '/..' . '/psr/clock/src',
),
'Monolog\\' =>
array (
0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
),
'GuzzleHttp\\Psr7\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
),
'GuzzleHttp\\Promise\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
),
'GuzzleHttp\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
),
'Fig\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/fig/http-message-util/src',
),
'Evenement\\' =>
array (
0 => __DIR__ . '/..' . '/evenement/evenement/src',
),
'Discord\\Http\\' =>
array (
0 => __DIR__ . '/..' . '/discord-php/http/src/Discord',
),
'Discord\\' =>
array (
0 => __DIR__ . '/..' . '/discord/interactions/discord',
1 => __DIR__ . '/..' . '/team-reflex/discord-php/src/Discord',
),
'DantSu\\PHPImageEditor\\' =>
array (
0 => __DIR__ . '/..' . '/dantsu/php-image-editor/src',
),
'DantSu\\OpenStreetMapStaticAPI\\' =>
array (
0 => __DIR__ . '/..' . '/dantsu/php-osm-static-api/src',
),
'Carbon\\Doctrine\\' =>
array (
0 => __DIR__ . '/..' . '/carbonphp/carbon-doctrine-types/src/Carbon/Doctrine',
),
'Carbon\\' =>
array (
0 => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon',
),
);
public static $prefixesPsr0 = array (
'T' =>
array (
'TrafficCophp' =>
array (
0 => __DIR__ . '/..' . '/trafficcophp/bytebuffer/src',
),
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'DateError' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateError.php',
'DateException' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateException.php',
'DateInvalidOperationException' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateInvalidOperationException.php',
'DateInvalidTimeZoneException' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateInvalidTimeZoneException.php',
'DateMalformedIntervalStringException' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateMalformedIntervalStringException.php',
'DateMalformedPeriodStringException' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateMalformedPeriodStringException.php',
'DateMalformedStringException' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateMalformedStringException.php',
'DateObjectError' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateObjectError.php',
'DateRangeError' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/DateRangeError.php',
'Override' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/Override.php',
'SQLite3Exception' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/SQLite3Exception.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit39e76b5f4d8c6722589be79886dc5716::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit39e76b5f4d8c6722589be79886dc5716::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit39e76b5f4d8c6722589be79886dc5716::$prefixesPsr0;
$loader->classMap = ComposerStaticInit39e76b5f4d8c6722589be79886dc5716::$classMap;
}, null, ClassLoader::class);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,419 +0,0 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => null,
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => true,
),
'versions' => array(
'__root__' => array(
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => null,
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'carbonphp/carbon-doctrine-types' => array(
'pretty_version' => '3.2.0',
'version' => '3.2.0.0',
'reference' => '18ba5ddfec8976260ead6e866180bd5d2f71aa1d',
'type' => 'library',
'install_path' => __DIR__ . '/../carbonphp/carbon-doctrine-types',
'aliases' => array(),
'dev_requirement' => false,
),
'dantsu/php-image-editor' => array(
'pretty_version' => '1.4.5',
'version' => '1.4.5.0',
'reference' => '59a3e922000767051d380a2c530c61344f1e79ec',
'type' => 'library',
'install_path' => __DIR__ . '/../dantsu/php-image-editor',
'aliases' => array(),
'dev_requirement' => false,
),
'dantsu/php-osm-static-api' => array(
'pretty_version' => '0.6.4',
'version' => '0.6.4.0',
'reference' => 'cf89dccfa4f27f6e76de0ab065b313d2f19de728',
'type' => 'library',
'install_path' => __DIR__ . '/../dantsu/php-osm-static-api',
'aliases' => array(),
'dev_requirement' => false,
),
'discord-php/http' => array(
'pretty_version' => 'v10.3.8',
'version' => '10.3.8.0',
'reference' => '0a9981dd5f8f96071f54d45e8d6fff2c6c295eb6',
'type' => 'library',
'install_path' => __DIR__ . '/../discord-php/http',
'aliases' => array(),
'dev_requirement' => false,
),
'discord/interactions' => array(
'pretty_version' => '2.2.0',
'version' => '2.2.0.0',
'reference' => 'a6fc0c877b75cf5ff5811f2ea69c5cc4ad6ac457',
'type' => 'library',
'install_path' => __DIR__ . '/../discord/interactions',
'aliases' => array(),
'dev_requirement' => false,
),
'evenement/evenement' => array(
'pretty_version' => 'v3.0.2',
'version' => '3.0.2.0',
'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc',
'type' => 'library',
'install_path' => __DIR__ . '/../evenement/evenement',
'aliases' => array(),
'dev_requirement' => false,
),
'fig/http-message-util' => array(
'pretty_version' => '1.1.5',
'version' => '1.1.5.0',
'reference' => '9d94dc0154230ac39e5bf89398b324a86f63f765',
'type' => 'library',
'install_path' => __DIR__ . '/../fig/http-message-util',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/guzzle' => array(
'pretty_version' => '7.9.2',
'version' => '7.9.2.0',
'reference' => 'd281ed313b989f213357e3be1a179f02196ac99b',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/guzzle',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/promises' => array(
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'reference' => 'f9c436286ab2892c7db7be8c8da4ef61ccf7b455',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/promises',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/psr7' => array(
'pretty_version' => '2.7.0',
'version' => '2.7.0.0',
'reference' => 'a70f5c95fb43bc83f07c9c948baa0dc1829bf201',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/psr7',
'aliases' => array(),
'dev_requirement' => false,
),
'monolog/monolog' => array(
'pretty_version' => '3.8.1',
'version' => '3.8.1.0',
'reference' => 'aef6ee73a77a66e404dd6540934a9ef1b3c855b4',
'type' => 'library',
'install_path' => __DIR__ . '/../monolog/monolog',
'aliases' => array(),
'dev_requirement' => false,
),
'nesbot/carbon' => array(
'pretty_version' => '3.8.4',
'version' => '3.8.4.0',
'reference' => '129700ed449b1f02d70272d2ac802357c8c30c58',
'type' => 'library',
'install_path' => __DIR__ . '/../nesbot/carbon',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/clock' => array(
'pretty_version' => '1.0.0',
'version' => '1.0.0.0',
'reference' => 'e41a24703d4560fd0acb709162f73b8adfc3aa0d',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/clock',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/clock-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/http-client' => array(
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-client',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-client-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/http-factory' => array(
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-factory',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-factory-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/http-message' => array(
'pretty_version' => '1.1',
'version' => '1.1.0.0',
'reference' => 'cb6ce4845ce34a8ad9e68117c10ee90a29919eba',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-message',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-message-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
),
),
'psr/log' => array(
'pretty_version' => '3.0.2',
'version' => '3.0.2.0',
'reference' => 'f16e1d5863e37f8d8c2a01719f5b34baa2b714d3',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/log',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/log-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '3.0.0',
),
),
'psr/simple-cache' => array(
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/simple-cache',
'aliases' => array(),
'dev_requirement' => false,
),
'ralouphie/getallheaders' => array(
'pretty_version' => '3.0.3',
'version' => '3.0.3.0',
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
'type' => 'library',
'install_path' => __DIR__ . '/../ralouphie/getallheaders',
'aliases' => array(),
'dev_requirement' => false,
),
'ratchet/pawl' => array(
'pretty_version' => 'v0.4.1',
'version' => '0.4.1.0',
'reference' => 'af70198bab77a582b31169d3cc3982bed25c161f',
'type' => 'library',
'install_path' => __DIR__ . '/../ratchet/pawl',
'aliases' => array(),
'dev_requirement' => false,
),
'ratchet/rfc6455' => array(
'pretty_version' => 'v0.3.1',
'version' => '0.3.1.0',
'reference' => '7c964514e93456a52a99a20fcfa0de242a43ccdb',
'type' => 'library',
'install_path' => __DIR__ . '/../ratchet/rfc6455',
'aliases' => array(),
'dev_requirement' => false,
),
'react/async' => array(
'pretty_version' => 'v4.3.0',
'version' => '4.3.0.0',
'reference' => '635d50e30844a484495713e8cb8d9e079c0008a5',
'type' => 'library',
'install_path' => __DIR__ . '/../react/async',
'aliases' => array(),
'dev_requirement' => false,
),
'react/cache' => array(
'pretty_version' => 'v1.2.0',
'version' => '1.2.0.0',
'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b',
'type' => 'library',
'install_path' => __DIR__ . '/../react/cache',
'aliases' => array(),
'dev_requirement' => false,
),
'react/child-process' => array(
'pretty_version' => 'v0.6.6',
'version' => '0.6.6.0',
'reference' => '1721e2b93d89b745664353b9cfc8f155ba8a6159',
'type' => 'library',
'install_path' => __DIR__ . '/../react/child-process',
'aliases' => array(),
'dev_requirement' => false,
),
'react/datagram' => array(
'pretty_version' => 'v1.10.0',
'version' => '1.10.0.0',
'reference' => '9236e1f5a67a6029be17d551e9858c487836c301',
'type' => 'library',
'install_path' => __DIR__ . '/../react/datagram',
'aliases' => array(),
'dev_requirement' => false,
),
'react/dns' => array(
'pretty_version' => 'v1.13.0',
'version' => '1.13.0.0',
'reference' => 'eb8ae001b5a455665c89c1df97f6fb682f8fb0f5',
'type' => 'library',
'install_path' => __DIR__ . '/../react/dns',
'aliases' => array(),
'dev_requirement' => false,
),
'react/event-loop' => array(
'pretty_version' => 'v1.5.0',
'version' => '1.5.0.0',
'reference' => 'bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354',
'type' => 'library',
'install_path' => __DIR__ . '/../react/event-loop',
'aliases' => array(),
'dev_requirement' => false,
),
'react/http' => array(
'pretty_version' => 'v1.11.0',
'version' => '1.11.0.0',
'reference' => '8db02de41dcca82037367f67a2d4be365b1c4db9',
'type' => 'library',
'install_path' => __DIR__ . '/../react/http',
'aliases' => array(),
'dev_requirement' => false,
),
'react/promise' => array(
'pretty_version' => 'v3.2.0',
'version' => '3.2.0.0',
'reference' => '8a164643313c71354582dc850b42b33fa12a4b63',
'type' => 'library',
'install_path' => __DIR__ . '/../react/promise',
'aliases' => array(),
'dev_requirement' => false,
),
'react/socket' => array(
'pretty_version' => 'v1.16.0',
'version' => '1.16.0.0',
'reference' => '23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1',
'type' => 'library',
'install_path' => __DIR__ . '/../react/socket',
'aliases' => array(),
'dev_requirement' => false,
),
'react/stream' => array(
'pretty_version' => 'v1.4.0',
'version' => '1.4.0.0',
'reference' => '1e5b0acb8fe55143b5b426817155190eb6f5b18d',
'type' => 'library',
'install_path' => __DIR__ . '/../react/stream',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/clock' => array(
'pretty_version' => 'v7.2.0',
'version' => '7.2.0.0',
'reference' => 'b81435fbd6648ea425d1ee96a2d8e68f4ceacd24',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/clock',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'v3.5.1',
'version' => '3.5.1.0',
'reference' => '74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/options-resolver' => array(
'pretty_version' => 'v7.2.0',
'version' => '7.2.0.0',
'reference' => '7da8fbac9dcfef75ffc212235d76b2754ce0cf50',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/options-resolver',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/polyfill-mbstring' => array(
'pretty_version' => 'v1.31.0',
'version' => '1.31.0.0',
'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/polyfill-php83' => array(
'pretty_version' => 'v1.31.0',
'version' => '1.31.0.0',
'reference' => '2fb86d65e2d424369ad2905e83b236a8805ba491',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-php83',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/translation' => array(
'pretty_version' => 'v7.2.2',
'version' => '7.2.2.0',
'reference' => 'e2674a30132b7cc4d74540d6c2573aa363f05923',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/translation',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/translation-contracts' => array(
'pretty_version' => 'v3.5.1',
'version' => '3.5.1.0',
'reference' => '4667ff3bd513750603a09c8dedbea942487fb07c',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/translation-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/translation-implementation' => array(
'dev_requirement' => false,
'provided' => array(
0 => '2.3|3.0',
),
),
'team-reflex/discord-php' => array(
'pretty_version' => 'v10.1.5',
'version' => '10.1.5.0',
'reference' => '23d1347025a7aa57e2a6918080bf2e1eaf1f0181',
'type' => 'library',
'install_path' => __DIR__ . '/../team-reflex/discord-php',
'aliases' => array(),
'dev_requirement' => false,
),
'trafficcophp/bytebuffer' => array(
'pretty_version' => 'v0.3',
'version' => '0.3.0.0',
'reference' => 'e94e5c87c41bc79c0f738b0fa89bad11d27ae0b4',
'type' => 'library',
'install_path' => __DIR__ . '/../trafficcophp/bytebuffer',
'aliases' => array(),
'dev_requirement' => false,
),
),
);

View File

@ -1,26 +0,0 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 80200)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.2.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

View File

@ -1 +0,0 @@
github: DantSu

View File

@ -1,6 +0,0 @@
/.idea
/.phpdoc
/phpdoc.xml
/phpdocumentor
/vendor
/composer.lock

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 Franck ALARY
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,83 +0,0 @@
[![Packagist](https://img.shields.io/packagist/dt/DantSu/php-image-editor.svg)](https://packagist.org/packages/DantSu/php-image-editor)
[![Latest Stable Version](https://poser.pugx.org/DantSu/php-image-editor/v/stable)](https://packagist.org/packages/DantSu/php-image-editor)
[![GitHub license](https://img.shields.io/github/license/DantSu/php-image-editor.svg)](https://github.com/DantSu/php-image-editor/blob/master/LICENSE)
# PHP Image Editor
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !
## ✨ Supporting
⭐ Star this repository to support this project. You will contribute to increase the visibility of this library 🙂
## Installation
Install this library easily with composer :
```cmd
composer require dantsu/php-image-editor
```
## How to use
### Example 1
Create a empty image, draw on it and display it :
```php
use \DantSu\PHPImageEditor\Image;
\header('Content-type: image/png');
$image = Image::newCanvas(500, 500)
->drawRectangle(0, 0, 500, 500, '#444')
->drawRectangle(0, 350, 500, 500, '#FF8800')
->writeText('I got the power !', __DIR__ . '/resources/font.ttf', 40, '#FFFFFF', Image::ALIGN_CENTER, 310)
->drawCircle(25, 100, 100, '#FF8800')
->drawCircle(25, 100, 95, '#000000FF')
->drawCircle(475, 100, 100, '#FF8800')
->drawCircle(475, 100, 95, '#000000FF');
for($i = 0; $i <= 360; $i+=30) {
$image
->drawArrowWithAngle(250, 200, $i, 80, 2, '#FF8800')
->drawArrowWithAngle(250, 200, ($i + 15), 50, 2, '#FF8800');
}
$image
->crop(450, 300, Image::ALIGN_CENTER, Image::ALIGN_MIDDLE)
->displayPNG();
```
![Sample 1](./src/samples/resources/sample1.png)
### Example 2
Apply a watermark on a photo and save it :
```php
use \DantSu\PHPImageEditor\Image;
Image::fromPath(__DIR__ . '/resources/photo.jpg')
->downscaleAndCrop(1920, 1080, Image::ALIGN_CENTER, Image::ALIGN_BOTTOM)
->pasteOn(
Image::fromPath(__DIR__ . '/resources/watermark.png')->downscaleProportion(300, 300),
Image::ALIGN_RIGHT,
Image::ALIGN_TOP
)
->saveJPG(__DIR__ . '/my-image.jpg', 70);
```
![Sample 2](./src/samples/resources/sample2.jpg)
## Documentation
See [DantSu\PHPImageEditor\Image](./docs/classes/DantSu/PHPImageEditor/Image.md) documentation class for more details.
## Contributing
Please fork this repository and contribute back using pull requests.
Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed.

View File

@ -1,33 +0,0 @@
{
"name": "dantsu/php-image-editor",
"type": "library",
"description": "PHP library to easily edit image with GD extension.",
"keywords": [
"php",
"gd2",
"edit",
"edition",
"editor",
"image",
"picture",
"photo"
],
"homepage": "https://github.com/DantSu/php-image-editor",
"license": "MIT",
"authors": [
{
"name": "Franck ALARY",
"homepage": "https://github.com/DantSu",
"role": "Developer"
}
],
"require": {
"php": ">=7.0",
"ext-gd": "*"
},
"autoload": {
"psr-4": {
"DantSu\\PHPImageEditor\\": "src/"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
# PHP Image Editor
This is an automatically generated documentation for **PHP Image Editor**.
## Namespaces
### \DantSu\PHPImageEditor
#### Classes
| Class | Description |
|--- |--- |
| [Image](./classes/DantSu/PHPImageEditor/Image.md) | DantSu\PHPImageEditor\Image is PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !|
---
> Automatically generated from source code comments on 2022-11-09 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,61 +0,0 @@
<?php
namespace DantSu\PHPImageEditor;
class Geometry2D
{
public static function degrees0to360(float $angle): float
{
while ($angle < 0 || $angle >= 360) {
if ($angle < 0) $angle += 360;
elseif ($angle >= 360) $angle -= 360;
}
return $angle;
}
public static function getDstXY(float $originX, float $originY, float $angle, float $length): array
{
$angle = 360 - $angle;
return [
'x' => $originX + \cos($angle * M_PI / 180) * $length,
'y' => $originY + \sin($angle * M_PI / 180) * $length
];
}
public static function getDstXYRounded(float $originX, float $originY, float $angle, float $length): array
{
$xy = Geometry2D::getDstXY($originX, $originY, $angle, $length);
return [
'x' => \round($xy['x']),
'y' => \round($xy['y'])
];
}
public static function getAngleAndLengthFromPoints(float $originX, float $originY, float $dstX, float $dstY): array
{
$width = $dstX - $originX;
$height = $dstY - $originY;
$diameter = \sqrt(\pow($width, 2) + \pow($height, 2));
if($width == 0) {
$angle = 90;
} elseif ($height == 0) {
$angle = 0;
} else {
$angle = \atan2(\abs($height), \abs($width)) * 180.0 / M_PI;
}
if($width < 0 && $height < 0) {
$angle += 180;
} elseif ($width < 0) {
$angle = 180 - $angle;
} elseif ($height < 0) {
$angle = 360 - $angle;
}
return [
'angle' => 360 - $angle,
'length' => $diameter
];
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

View File

@ -1,28 +0,0 @@
<?php
require_once '../Geometry2D.php';
require_once '../Image.php';
use \DantSu\PHPImageEditor\Image;
\header('Content-type: image/png');
$image = Image::newCanvas(500, 500)
->drawRectangle(0, 0, 500, 500, '#444')
->drawRectangle(0, 350, 500, 500, '#FF8800')
->writeText('I got the power !', __DIR__ . '/resources/font.ttf', 40, '#FFFFFF', Image::ALIGN_CENTER, 310)
->drawCircle(25, 100, 100, '#FF8800')
->drawCircle(25, 100, 95, '#000000FF')
->drawCircle(475, 100, 100, '#FF8800')
->drawCircle(475, 100, 95, '#000000FF');
for($i = 0; $i <= 360; $i+=30) {
$image
->drawArrowWithAngle(250, 200, $i, 80, 2, '#FF8800')
->drawArrowWithAngle(250, 200, ($i + 15), 50, 2, '#FF8800');
}
$image
->crop(450, 300)
->displayPNG();

View File

@ -1,18 +0,0 @@
<?php
require_once '../Geometry2D.php';
require_once '../Image.php';
use \DantSu\PHPImageEditor\Image;
\header('Content-type: image/jpg');
Image::fromPath(__DIR__ . '/resources/photo.jpg')
->downscaleAndCrop(1920, 1080, Image::ALIGN_CENTER, Image::ALIGN_BOTTOM)
->pasteOn(
Image::fromPath(__DIR__ . '/resources/watermark.png')->downscaleProportion(300, 300),
Image::ALIGN_RIGHT,
Image::ALIGN_TOP
)
->displayJPG(50);

View File

@ -1,19 +0,0 @@
<?php
require_once '../Geometry2D.php';
require_once '../Image.php';
use \DantSu\PHPImageEditor\Image;
\header('Content-type: image/png');
$image = Image::fromPath(__DIR__ . '/resources/photo.jpg')->downscaleAndCrop(512, 1024);
$image2 = clone $image;
$image2->drawRectangle(128, 128, 384, 384, '#8822AA');
Image::newCanvas(1024, 1024)
->pasteOn($image, 0, 0)
->pasteOn($image2, 512, 0)
->displayPNG();

View File

@ -1,23 +0,0 @@
<?php
require_once '../Geometry2D.php';
require_once '../Image.php';
use \DantSu\PHPImageEditor\Image;
\header('Content-type: image/png');
Image::fromPath(__DIR__ . '/resources/photo.jpg')
->downscaleAndCrop(1920, 1080, Image::ALIGN_CENTER, Image::ALIGN_BOTTOM)
->drawPolygon([110, 500, 240, 250, 400, 140, 650, 280, 400, 400, 800, 510, 400, 950, 180, 620, 230, 540], '#88229988')
->drawCircle(450, 600, 200, '#FFFFFF88')
->pasteOn(
Image::newCanvas(1920, 1080)
->drawPolygon([1110, 500, 1240, 250, 1400, 140, 1650, 280, 1400, 400, 1800, 510, 1400, 950, 1180, 620, 1230, 540], '#882299')
->drawCircle(1450, 600, 200)
->setOpacity(0.6),
0,
0
)
->displayPNG();

View File

@ -1,14 +0,0 @@
<?php
require_once '../Geometry2D.php';
require_once '../Image.php';
use \DantSu\PHPImageEditor\Image;
\header('Content-type: image/png');
Image::fromPath(__DIR__ . '/resources/sample5_base.png')
->alphaMask(Image::fromPath(__DIR__ . '/resources/sample5_mask.png'))
->crop(494, 494, 9, 12)
->setOpacity(0.5)
->displayPNG();

View File

@ -1,24 +0,0 @@
<?php
require_once '../Geometry2D.php';
require_once '../Image.php';
use \DantSu\PHPImageEditor\Image;
\header('Content-type: image/png');
$image1 = Image::newCanvas(500, 500);
$bbox = $image1->writeTextAndGetBoundingBox('I got the power !', __DIR__ . '/resources/font.ttf', 40, '#FFFFFF', Image::ALIGN_RIGHT, Image::ALIGN_BOTTOM, Image::ALIGN_RIGHT, Image::ALIGN_BOTTOM, 0, 5);
Image::newCanvas(500, 500)
->drawPolygon(
[
$bbox['top-left']['x'], $bbox['top-left']['y'],
$bbox['top-right']['x'], $bbox['top-right']['y'],
$bbox['bottom-right']['x'], $bbox['bottom-right']['y'],
$bbox['bottom-left']['x'], $bbox['bottom-left']['y']
],
'00000088'
)
->pasteOn($image1)
->displayPNG();

View File

@ -1 +0,0 @@
github: DantSu

View File

@ -1,6 +0,0 @@
/.idea
/.phpdoc
/phpdoc.xml
/phpdocumentor
/vendor
/composer.lock

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 Franck ALARY
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,77 +0,0 @@
[![Packagist](https://img.shields.io/packagist/dt/DantSu/php-osm-static-api.svg)](https://packagist.org/packages/DantSu/php-osm-static-api)
[![Latest Stable Version](https://poser.pugx.org/DantSu/php-osm-static-api/v/stable)](https://packagist.org/packages/DantSu/php-osm-static-api)
[![GitHub license](https://img.shields.io/github/license/DantSu/php-osm-static-api.svg)](https://github.com/DantSu/php-osm-static-api/blob/master/LICENSE)
# PHP OpenStreetMap Static API
PHP library to easily get static image from OpenStreetMap with markers, lines, circles and polygons.
This project uses the [Tile Server](https://wiki.openstreetmap.org/wiki/Tile_servers) of the OpenStreetMap Foundation which runs entirely on donated resources, see [Tile Usage Policy](https://operations.osmfoundation.org/policies/tiles/) for more information.
## ✨ Supporting
⭐ Star this repository to support this project. You will contribute to increase the visibility of this library 🙂
## Installation
Install this library easily with composer :
```cmd
composer require dantsu/php-osm-static-api
```
## How to use
Generate OpenStreetMap static image with marker and line :
```php
use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Polygon;
use \DantSu\OpenStreetMapStaticAPI\Markers;
\header('Content-type: image/png');
(new OpenStreetMap(new LatLng(44.351933, 2.568113), 17, 600, 400))
->addMarkers(
(new Markers(__DIR__ . '/resources/marker.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
->addMarker(new LatLng(44.351510, 2.570020))
->addMarker(new LatLng(44.351873, 2.566250))
)
->addDraw(
(new Polygon('FF0000', 2, 'FF0000DD'))
->addPoint(new LatLng(44.351172, 2.571092))
->addPoint(new LatLng(44.352097, 2.570045))
->addPoint(new LatLng(44.352665, 2.568107))
->addPoint(new LatLng(44.352887, 2.566503))
->addPoint(new LatLng(44.352806, 2.565972))
->addPoint(new LatLng(44.351517, 2.565672))
)
->getImage()
->displayPNG();
```
![Exported OpenStreetMap image](./src/samples/resources/sample1.png)
## Documentation
| Class | Description |
|--- |--- |
| [Circle](./docs/classes/DantSu/OpenStreetMapStaticAPI/Circle.md) | DantSu\OpenStreetMapStaticAPI\Circle draw circle on the map.|
| [LatLng](./docs/classes/DantSu/OpenStreetMapStaticAPI/LatLng.md) | DantSu\OpenStreetMapStaticAPI\LatLng define latitude and longitude for map, lines, markers.|
| [Line](./docs/classes/DantSu/OpenStreetMapStaticAPI/Line.md) | DantSu\OpenStreetMapStaticAPI\Line draw line on the map.|
| [MapData](./docs/classes/DantSu/OpenStreetMapStaticAPI/MapData.md) | DantSu\OpenStreetMapStaticAPI\MapData convert latitude and longitude to image pixel position.|
| [Markers](./docs/classes/DantSu/OpenStreetMapStaticAPI/Markers.md) | DantSu\OpenStreetMapStaticAPI\Markers display markers on the map.|
| [OpenStreetMap](./docs/classes/DantSu/OpenStreetMapStaticAPI/OpenStreetMap.md) | DantSu\OpenStreetMapStaticAPI\OpenStreetMap is a PHP library created for easily get static image from OpenStreetMap with markers, lines, polygons and circles.|
| [Polygon](./docs/classes/DantSu/OpenStreetMapStaticAPI/Polygon.md) | DantSu\OpenStreetMapStaticAPI\Polygon draw polygon on the map.|
| [TileLayer](./docs/classes/DantSu/OpenStreetMapStaticAPI/TileLayer.md) | DantSu\OpenStreetMapStaticAPI\TileLayer define tile server url and related configuration|
| [XY](./docs/classes/DantSu/OpenStreetMapStaticAPI/XY.md) | DantSu\OpenStreetMapStaticAPI\XY define X and Y pixel position for map, lines, markers.|
## Contributing
Please fork this repository and contribute back using pull requests.
Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed.

View File

@ -1,33 +0,0 @@
{
"name": "dantsu/php-osm-static-api",
"type": "library",
"description": "PHP library to easily get static image from OpenStreetMap (OSM), add markers and draw lines.",
"keywords": [
"php",
"osm",
"openstreetmap",
"map",
"static",
"image",
"maps",
"api"
],
"homepage": "https://github.com/DantSu/php-osm-static-api",
"license": "MIT",
"authors": [
{
"name": "Franck ALARY",
"homepage": "https://github.com/DantSu",
"role": "Developer"
}
],
"require": {
"php": ">=7.0",
"dantsu/php-image-editor": "^1.3"
},
"autoload": {
"psr-4": {
"DantSu\\OpenStreetMapStaticAPI\\": "src/"
}
}
}

View File

@ -1,150 +0,0 @@
# Circle
DantSu\OpenStreetMapStaticAPI\Circle draw circle on the map.
* Full name: `\DantSu\OpenStreetMapStaticAPI\Circle`
* This class implements: \DantSu\OpenStreetMapStaticAPI\Interfaces\Draw
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- [__construct](#-__construct)
- [setEdgePoint](#-setedgepoint)
- [setRadius](#-setradius)
- [draw](#-draw)
- [getBoundingBox](#-getboundingbox)
### ->__construct
Circle constructor.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `center` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the circle center |
| `strokeColor` | **string** | Hexadecimal string color |
| `strokeWeight` | **int** | pixel weight of the line |
| `fillColor` | **string** | Hexadecimal string color |
---
### ->setEdgePoint
Set a latitude and longitude to define the radius of the circle.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `edge` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the edge point of a circle |
#### Return Value:
**$this** : Fluent interface
---
### ->setRadius
Set the radius of the circle in meters.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `radius` | **float** | radius of a circle in meters |
#### Return Value:
**$this** : Fluent interface
---
### ->draw
Draw the circle on the map image.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `image` | **\DantSu\PHPImageEditor\Image** | The map image (An instance of DantSu\PHPImageEditor\Image) |
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | Bounding box of the map |
#### Return Value:
**$this** : Fluent interface
#### See Also:
* https://github.com/DantSu/php-image-editor - See more about DantSu\PHPImageEditor\Image
---
### ->getBoundingBox
Get bounding box of the shape
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng[]** :
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,63 +0,0 @@
# Draw
* Full name: `\DantSu\OpenStreetMapStaticAPI\Interfaces\Draw`
* Parent interface: [](../../../../classes.md)
## Methods
### ->getBoundingBox
#### Return Value:
**array** :
---
### ->draw
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `image` | **\DantSu\PHPImageEditor\Image** | |
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | |
#### Return Value:
**mixed** :
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,85 +0,0 @@
# LatLng
DantSu\OpenStreetMapStaticAPI\LatLng define latitude and longitude for map, lines, markers.
..
* Full name: `\DantSu\OpenStreetMapStaticAPI\LatLng`
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- [__construct](#-__construct)
- [getLat](#-getlat)
- [getLng](#-getlng)
### ->__construct
LatLng constructor.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `lat` | **float** | Latitude |
| `lng` | **float** | Longitude |
---
### ->getLat
Get latitude
#### Return Value:
**float** : Latitude
---
### ->getLng
Get longitude
#### Return Value:
**float** : Longitude
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,122 +0,0 @@
# Line
DantSu\OpenStreetMapStaticAPI\Line draw line on the map.
* Full name: `\DantSu\OpenStreetMapStaticAPI\Line`
* This class implements: \DantSu\OpenStreetMapStaticAPI\Interfaces\Draw
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- [__construct](#-__construct)
- [addPoint](#-addpoint)
- [draw](#-draw)
- [getBoundingBox](#-getboundingbox)
### ->__construct
Line constructor.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `color` | **string** | Hexadecimal string color |
| `weight` | **int** | pixel weight of the line |
---
### ->addPoint
Add a latitude and longitude to the multi-points line
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `latLng` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude to add |
#### Return Value:
**$this** : Fluent interface
---
### ->draw
Draw the line on the map image.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `image` | **\DantSu\PHPImageEditor\Image** | The map image (An instance of DantSu\PHPImageEditor\Image) |
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | Bounding box of the map |
#### Return Value:
**$this** : Fluent interface
#### See Also:
* https://github.com/DantSu/php-image-editor - See more about DantSu\PHPImageEditor\Image
---
### ->getBoundingBox
Get bounding box of the shape
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng[]** :
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,464 +0,0 @@
# MapData
DantSu\OpenStreetMapStaticAPI\MapData convert latitude and longitude to image pixel position.
* Full name: `\DantSu\OpenStreetMapStaticAPI\MapData`
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- *(static)* [lngToXTile](#lngtoxtile)
- *(static)* [latToYTile](#lattoytile)
- *(static)* [xTileToLng](#xtiletolng)
- *(static)* [yTileToLat](#ytiletolat)
- *(static)* [getBoundingBoxFromPoints](#getboundingboxfrompoints)
- *(static)* [getCenterAndZoomFromBoundingBox](#getcenterandzoomfromboundingbox)
- [__construct](#-__construct)
- [getLatLngTopLeft](#-getlatlngtopleft)
- [getLatLngTopRight](#-getlatlngtopright)
- [getLatLngBottomLeft](#-getlatlngbottomleft)
- [getLatLngBottomRight](#-getlatlngbottomright)
- [getOutputSize](#-getoutputsize)
- [getZoom](#-getzoom)
- [getTileSize](#-gettilesize)
- [getTileTopLeft](#-gettiletopleft)
- [getTileBottomRight](#-gettilebottomright)
- [getMapCropTopLeft](#-getmapcroptopleft)
- [getMapCropBottomRight](#-getmapcropbottomright)
- [convertLatLngToPxPosition](#-convertlatlngtopxposition)
### ::lngToXTile
Convert longitude and zoom to horizontal OpenStreetMap tile number and pixel position.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `lon` | **float** | Longitude |
| `zoom` | **int** | Zoom |
| `tileSize` | **int** | Tile size |
#### Return Value:
**int[]** : OpenStreetMap tile id and pixel position of the given longitude and zoom
---
### ::latToYTile
Convert latitude and zoom to vertical OpenStreetMap tile number and pixel position.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `lat` | **float** | Latitude |
| `zoom` | **int** | Zoom |
| `tileSize` | **int** | Tile size |
#### Return Value:
**int[]** : OpenStreetMap tile id and pixel position of the given latitude and zoom
---
### ::xTileToLng
Convert horizontal OpenStreetMap tile number ad zoom to longitude.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `id` | **int** | Horizontal OpenStreetMap tile id |
| `position` | **int** | Horizontal pixel position on tile |
| `zoom` | **int** | Zoom |
| `tileSize` | **int** | Tile size |
#### Return Value:
**float** : Longitude of the given OpenStreetMap tile id and zoom
---
### ::yTileToLat
Convert vertical OpenStreetMap tile number and zoom to latitude.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `id` | **int** | Vertical OpenStreetMap tile id |
| `position` | **int** | Vertical pixel position on tile |
| `zoom` | **int** | Zoom |
| `tileSize` | **int** | Tile size |
#### Return Value:
**float** : Latitude of the given OpenStreetMap tile id and zoom
---
### ::getBoundingBoxFromPoints
Transform array of LatLng to bounding box
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `points` | **\DantSu\OpenStreetMapStaticAPI\LatLng[]** | |
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng[]** :
---
### ::getCenterAndZoomFromBoundingBox
Get center and zoom from two points.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `topLeft` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | |
| `bottomRight` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | |
| `padding` | **int** | |
| `imageWidth` | **int** | |
| `imageHeight` | **int** | |
| `tileSize` | **int** | |
#### Return Value:
**array** : center : LatLng, zoom : int
---
### ->__construct
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `centerMap` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | |
| `zoom` | **int** | |
| `outputSize` | **\DantSu\OpenStreetMapStaticAPI\XY** | |
| `tileSize` | **int** | |
---
### ->getLatLngTopLeft
Get latitude and longitude of top left image
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng** : Latitude and longitude of top left image
---
### ->getLatLngTopRight
Get latitude and longitude of top right image
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng** : Latitude and longitude of top right image
---
### ->getLatLngBottomLeft
Get latitude and longitude of bottom left image
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng** : Latitude and longitude of bottom left image
---
### ->getLatLngBottomRight
Get latitude and longitude of bottom right image
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng** : Latitude and longitude of bottom right image
---
### ->getOutputSize
Get width and height of the image in pixel
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\XY** : Width and height of the image in pixel
---
### ->getZoom
Get the zoom
#### Return Value:
**int** : zoom
---
### ->getTileSize
Get tile size
#### Return Value:
**int** : tile size
---
### ->getTileTopLeft
Get top left tile numbers
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\XY** : top left tile numbers
---
### ->getTileBottomRight
Get bottom right tile numbers
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\XY** : bottom right tile numbers
---
### ->getMapCropTopLeft
Get top left crop pixels
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\XY** : top left crop pixels
---
### ->getMapCropBottomRight
Get bottom right crop pixels
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\XY** : bottom right crop pixels
---
### ->convertLatLngToPxPosition
Convert a latitude and longitude to a XY pixel position in the image
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `latLng` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude to be converted |
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\XY** : Pixel position of latitude and longitude in the image
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,158 +0,0 @@
# Markers
DantSu\OpenStreetMapStaticAPI\Markers display markers on the map.
* Full name: `\DantSu\OpenStreetMapStaticAPI\Markers`
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Constants
| Constant | Value |
|:--- |:--- |
|`\DantSu\OpenStreetMapStaticAPI\Markers::ANCHOR_LEFT`|&#039;left&#039;|
|`\DantSu\OpenStreetMapStaticAPI\Markers::ANCHOR_CENTER`|&#039;center&#039;|
|`\DantSu\OpenStreetMapStaticAPI\Markers::ANCHOR_RIGHT`|&#039;right&#039;|
|`\DantSu\OpenStreetMapStaticAPI\Markers::ANCHOR_TOP`|&#039;top&#039;|
|`\DantSu\OpenStreetMapStaticAPI\Markers::ANCHOR_MIDDLE`|&#039;middle&#039;|
|`\DantSu\OpenStreetMapStaticAPI\Markers::ANCHOR_BOTTOM`|&#039;bottom&#039;|
## Methods
- [__construct](#-__construct)
- [addMarker](#-addmarker)
- [setAnchor](#-setanchor)
- [draw](#-draw)
- [getBoundingBox](#-getboundingbox)
### ->__construct
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `pathImage` | **mixed** | |
---
### ->addMarker
Add a marker on the map.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `coordinate` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the marker |
#### Return Value:
**$this** : Fluent interface
---
### ->setAnchor
Define the anchor point of the image marker.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `horizontalAnchor` | **int&#124;string** | Horizontal anchor in pixel or you can use `Markers::ANCHOR_LEFT`, `Markers::ANCHOR_CENTER`, `Markers::ANCHOR_RIGHT` |
| `verticalAnchor` | **int&#124;string** | Vertical anchor in pixel or you can use `Markers::ANCHOR_TOP`, `Markers::ANCHOR_MIDDLE`, `Markers::ANCHOR_BOTTOM` |
#### Return Value:
**$this** : Fluent interface
---
### ->draw
Draw markers on the image map.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `image` | **\DantSu\PHPImageEditor\Image** | The map image (An instance of DantSu\PHPImageEditor\Image) |
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | Bounding box of the map |
#### Return Value:
**$this** : Fluent interface
#### See Also:
* https://github.com/DantSu/php-image-editor - See more about DantSu\PHPImageEditor\Image
---
### ->getBoundingBox
Get bounding box of markers
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng[]** :
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,341 +0,0 @@
# OpenStreetMap
DantSu\OpenStreetMapStaticAPI\OpenStreetMap is a PHP library created for easily get static image from OpenStreetMap with markers, lines, polygons and circles.
* Full name: `\DantSu\OpenStreetMapStaticAPI\OpenStreetMap`
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- *(static)* [createFromLatLngZoom](#createfromlatlngzoom)
- *(static)* [createFromBoundingBox](#createfromboundingbox)
- [__construct](#-__construct)
- [addLayer](#-addlayer)
- [addMarkers](#-addmarkers)
- [addDraw](#-adddraw)
- [fitToDraws](#-fittodraws)
- [fitToMarkers](#-fittomarkers)
- [fitToMarkersAndDraws](#-fittomarkersanddraws)
- [fitToPoints](#-fittopoints)
- [getMapData](#-getmapdata)
- [getImage](#-getimage)
### ::createFromLatLngZoom
Create new instance of OpenStreetMap.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `centerMap` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the map center |
| `zoom` | **int** | Zoom |
| `imageWidth` | **int** | Width of the generated map image |
| `imageHeight` | **int** | Height of the generated map image |
| `tileLayer` | **\DantSu\OpenStreetMapStaticAPI\TileLayer** | Tile server configuration, defaults to OpenStreetMaps tile server |
| `tileSize` | **int** | Tile size in pixels |
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\OpenStreetMap** :
---
### ::createFromBoundingBox
Create new instance of OpenStreetMap.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `topLeft` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the map top left |
| `bottomRight` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the map bottom right |
| `padding` | **int** | Padding to add before top left and after bottom right position. |
| `imageWidth` | **int** | Width of the generated map image |
| `imageHeight` | **int** | Height of the generated map image |
| `tileLayer` | **\DantSu\OpenStreetMapStaticAPI\TileLayer** | Tile server configuration, defaults to OpenStreetMaps tile server |
| `tileSize` | **int** | Tile size in pixels |
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\OpenStreetMap** :
---
### ->__construct
OpenStreetMap constructor.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `centerMap` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the map center |
| `zoom` | **int** | Zoom |
| `imageWidth` | **int** | Width of the generated map image |
| `imageHeight` | **int** | Height of the generated map image |
| `tileLayer` | **\DantSu\OpenStreetMapStaticAPI\TileLayer** | Tile server configuration, defaults to OpenStreetMaps tile server |
| `tileSize` | **int** | Tile size in pixels |
---
### ->addLayer
Add tile layer to the map
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `layer` | **\DantSu\OpenStreetMapStaticAPI\TileLayer** | An instance of TileLayer |
#### Return Value:
**$this** : Fluent interface
---
### ->addMarkers
Add markers on the map
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `markers` | **\DantSu\OpenStreetMapStaticAPI\Markers** | An instance of Markers |
#### Return Value:
**$this** : Fluent interface
---
### ->addDraw
Add a line on the map
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `draw` | **\DantSu\OpenStreetMapStaticAPI\Interfaces\Draw** | An instance of Line |
#### Return Value:
**$this** : Fluent interface
---
### ->fitToDraws
Fit map to draws.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `padding` | **int** | Padding in pixel |
#### Return Value:
**$this** : Fluent interface
---
### ->fitToMarkers
Fit map to markers.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `padding` | **int** | Padding in pixel |
#### Return Value:
**$this** : Fluent interface
---
### ->fitToMarkersAndDraws
Fit map to draws and markers.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `padding` | **int** | Padding in pixel |
#### Return Value:
**$this** : Fluent interface
---
### ->fitToPoints
Fit map to an array of points.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `points` | **\DantSu\OpenStreetMapStaticAPI\LatLng[]** | LatLng points |
| `padding` | **int** | Padding in pixel |
#### Return Value:
**$this** : Fluent interface
---
### ->getMapData
Get data about the generated map (bounding box, size, OSM tile ids...)
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\MapData** : data about the generated map (bounding box, size, OSM tile ids...)
#### See Also:
* https://github.com/DantSu/php-osm-static-api/blob/master/docs/classes/DantSu/OpenStreetMapStaticAPI/MapData.md - See more about MapData
---
### ->getImage
Get the map image with markers and lines.
#### Return Value:
**\DantSu\PHPImageEditor\Image** : An instance of DantSu\PHPImageEditor\Image
#### See Also:
* https://github.com/DantSu/php-image-editor - See more about DantSu\PHPImageEditor\Image
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,123 +0,0 @@
# Polygon
DantSu\OpenStreetMapStaticAPI\Polygon draw polygon on the map.
* Full name: `\DantSu\OpenStreetMapStaticAPI\Polygon`
* This class implements: \DantSu\OpenStreetMapStaticAPI\Interfaces\Draw
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- [__construct](#-__construct)
- [addPoint](#-addpoint)
- [draw](#-draw)
- [getBoundingBox](#-getboundingbox)
### ->__construct
Polygon constructor.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `strokeColor` | **string** | Hexadecimal string color |
| `strokeWeight` | **int** | pixel weight of the line |
| `fillColor` | **string** | Hexadecimal string color |
---
### ->addPoint
Add a latitude and longitude to the polygon
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `latLng` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude to add |
#### Return Value:
**$this** : Fluent interface
---
### ->draw
Draw the polygon on the map image.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `image` | **\DantSu\PHPImageEditor\Image** | The map image (An instance of DantSu\PHPImageEditor\Image) |
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | Bounding box of the map |
#### Return Value:
**$this** : Fluent interface
#### See Also:
* https://github.com/DantSu/php-image-editor - See more about DantSu\PHPImageEditor\Image
---
### ->getBoundingBox
Get bounding box of the shape
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng[]** :
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,289 +0,0 @@
# TileLayer
DantSu\OpenStreetMapStaticAPI\TileLayer define tile server url and related configuration
* Full name: `\DantSu\OpenStreetMapStaticAPI\TileLayer`
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- *(static)* [defaultTileLayer](#defaulttilelayer)
- [__construct](#-__construct)
- [setOpacity](#-setopacity)
- [setMaxZoom](#-setmaxzoom)
- [getMaxZoom](#-getmaxzoom)
- [setMinZoom](#-setminzoom)
- [getMinZoom](#-getminzoom)
- [checkZoom](#-checkzoom)
- [getTileUrl](#-gettileurl)
- [getAttributionText](#-getattributiontext)
- [getTile](#-gettile)
### ::defaultTileLayer
Default tile server. OpenStreetMaps with related attribution text
* This method is **static**.
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\TileLayer** : default tile server
---
### ->__construct
TileLayer constructor
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `url` | **string** | tile server url with placeholders (`x`, `y`, `z`, `r`, `s`) |
| `attributionText` | **string** | tile server attribution text |
| `subdomains` | **string** | tile server subdomains |
| `curlOptions` | **array** | Array of curl options |
| `failCurlOnError` | **bool** | If true, curl will throw an exception on error. |
---
### ->setOpacity
Set opacity of the layer
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `opacity` | **float** | Opacity value (0 to 1) |
#### Return Value:
**$this** : Fluent interface
---
### ->setMaxZoom
Set a max zoom value
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `maxZoom` | **int** | |
#### Return Value:
**$this** : Fluent interface
---
### ->getMaxZoom
Get max zoom value
#### Return Value:
**int** :
---
### ->setMinZoom
Set a min zoom value
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `minZoom` | **int** | |
#### Return Value:
**$this** : Fluent interface
---
### ->getMinZoom
Get min zoom value
#### Return Value:
**int** :
---
### ->checkZoom
Check if zoom value is between min zoom and max zoom
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `zoom` | **int** | Zoom value to be checked |
#### Return Value:
**int** :
---
### ->getTileUrl
Get tile url for coordinates and zoom level
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `x` | **int** | x coordinate |
| `y` | **int** | y coordinate |
| `z` | **int** | zoom level |
#### Return Value:
**string** : tile url
---
### ->getAttributionText
Get attribution text
#### Return Value:
**string** : Attribution text
---
### ->getTile
Get an image tile
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `x` | **float** | |
| `y` | **float** | |
| `z` | **int** | |
| `tileSize` | **int** | |
#### Return Value:
**\DantSu\PHPImageEditor\Image** : Image instance containing the tile
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,127 +0,0 @@
# GeographicConverter
* Full name: `\DantSu\OpenStreetMapStaticAPI\Utils\GeographicConverter`
## Methods
- *(static)* [earthRadiusAtLatitude](#earthradiusatlatitude)
- *(static)* [metersToLatLng](#meterstolatlng)
- *(static)* [latLngToMeters](#latlngtometers)
- *(static)* [getCenter](#getcenter)
### ::earthRadiusAtLatitude
Calculate the earth radius at the given latitude
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `lat` | **float** | |
#### Return Value:
**float** :
---
### ::metersToLatLng
Convert distance and angle from a point to latitude and longitude
0 : top, 90 : right; 180 : bottom, 270 : left
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `from` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Starting coordinate |
| `distance` | **float** | Distance in meters |
| `angle` | **float** | Angle in degrees |
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng** :
---
### ::latLngToMeters
Get distance in meters between two points.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `from` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Starting coordinate |
| `end` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Ending coordinate |
#### Return Value:
**float** :
---
### ::getCenter
Get center between two coordinates.
* This method is **static**.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `point1` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Vertical OpenStreetMap tile id |
| `point2` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Vertical pixel position on tile |
#### Return Value:
**\DantSu\OpenStreetMapStaticAPI\LatLng** : midpoint between the given coordinates
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,85 +0,0 @@
# XY
DantSu\OpenStreetMapStaticAPI\XY define X and Y pixel position for map, lines, markers.
..
* Full name: `\DantSu\OpenStreetMapStaticAPI\XY`
**See Also:**
* https://github.com/DantSu/php-osm-static-api - Github page of this project
## Methods
- [__construct](#-__construct)
- [getX](#-getx)
- [getY](#-gety)
### ->__construct
XY constructor.
#### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `x` | **int** | X |
| `y` | **int** | Y |
---
### ->getX
Get X
#### Return Value:
**int** : X
---
### ->getY
Get Y
#### Return Value:
**int** : Y
---
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,54 +0,0 @@
# PHP OpenStreetMap Static API
This is an automatically generated documentation for **PHP OpenStreetMap Static API**.
## Namespaces
### \DantSu\OpenStreetMapStaticAPI
#### Classes
| Class | Description |
|--- |--- |
| [Circle](./classes/DantSu/OpenStreetMapStaticAPI/Circle.md) | DantSu\OpenStreetMapStaticAPI\Circle draw circle on the map.|
| [LatLng](./classes/DantSu/OpenStreetMapStaticAPI/LatLng.md) | DantSu\OpenStreetMapStaticAPI\LatLng define latitude and longitude for map, lines, markers.|
| [Line](./classes/DantSu/OpenStreetMapStaticAPI/Line.md) | DantSu\OpenStreetMapStaticAPI\Line draw line on the map.|
| [MapData](./classes/DantSu/OpenStreetMapStaticAPI/MapData.md) | DantSu\OpenStreetMapStaticAPI\MapData convert latitude and longitude to image pixel position.|
| [Markers](./classes/DantSu/OpenStreetMapStaticAPI/Markers.md) | DantSu\OpenStreetMapStaticAPI\Markers display markers on the map.|
| [OpenStreetMap](./classes/DantSu/OpenStreetMapStaticAPI/OpenStreetMap.md) | DantSu\OpenStreetMapStaticAPI\OpenStreetMap is a PHP library created for easily get static image from OpenStreetMap with markers, lines, polygons and circles.|
| [Polygon](./classes/DantSu/OpenStreetMapStaticAPI/Polygon.md) | DantSu\OpenStreetMapStaticAPI\Polygon draw polygon on the map.|
| [TileLayer](./classes/DantSu/OpenStreetMapStaticAPI/TileLayer.md) | DantSu\OpenStreetMapStaticAPI\TileLayer define tile server url and related configuration|
| [XY](./classes/DantSu/OpenStreetMapStaticAPI/XY.md) | DantSu\OpenStreetMapStaticAPI\XY define X and Y pixel position for map, lines, markers.|
### \DantSu\OpenStreetMapStaticAPI\Interfaces
#### Interfaces
| Interface | Description |
|--- |--- |
| [Draw](./classes/DantSu/OpenStreetMapStaticAPI/Interfaces/Draw.md) | |
### \DantSu\OpenStreetMapStaticAPI\Utils
#### Classes
| Class | Description |
|--- |--- |
| [GeographicConverter](./classes/DantSu/OpenStreetMapStaticAPI/Utils/GeographicConverter.md) | |
---
> Automatically generated from source code comments on 2023-07-30 using [phpDocumentor](http://www.phpdoc.org/)

View File

@ -1,126 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
use DantSu\OpenStreetMapStaticAPI\Interfaces\Draw;
use DantSu\OpenStreetMapStaticAPI\Utils\GeographicConverter;
use DantSu\PHPImageEditor\Geometry2D;
use DantSu\PHPImageEditor\Image;
/**
* DantSu\OpenStreetMapStaticAPI\Circle draw circle on the map.
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class Circle implements Draw
{
/**
* @var string
*/
private $strokeColor = '000000';
/**
* @var int
*/
private $strokeWeight = 1;
/**
* @var string
*/
private $fillColor = '000000';
/**
* @var LatLng
*/
private $center = null;
/**
* @var LatLng
*/
private $edge = null;
/**
* Circle constructor.
*
* @param LatLng $center Latitude and longitude of the circle center
* @param string $strokeColor Hexadecimal string color
* @param int $strokeWeight pixel weight of the line
* @param string $fillColor Hexadecimal string color
*/
public function __construct(LatLng $center, string $strokeColor, int $strokeWeight, string $fillColor)
{
$this->center = $center;
$this->edge = $center;
$this->strokeColor = \str_replace('#', '', $strokeColor);
$this->strokeWeight = $strokeWeight > 0 ? $strokeWeight : 0;
$this->fillColor = \str_replace('#', '', $fillColor);
}
/**
* Set a latitude and longitude to define the radius of the circle.
*
* @param LatLng $edge Latitude and longitude of the edge point of a circle
* @return $this Fluent interface
*/
public function setEdgePoint(LatLng $edge): Circle
{
$this->edge = $edge;
return $this;
}
/**
* Set the radius of the circle in meters.
*
* @param float $radius radius of a circle in meters
* @return $this Fluent interface
*/
public function setRadius(float $radius): Circle
{
$this->edge = GeographicConverter::metersToLatLng($this->center, $radius, 45);
return $this;
}
/**
* Draw the circle on the map image.
*
* @see https://github.com/DantSu/php-image-editor See more about DantSu\PHPImageEditor\Image
*
* @param Image $image The map image (An instance of DantSu\PHPImageEditor\Image)
* @param MapData $mapData Bounding box of the map
* @return $this Fluent interface
*/
public function draw(Image $image, MapData $mapData): Circle
{
$center = $mapData->convertLatLngToPxPosition($this->center);
$edge = $mapData->convertLatLngToPxPosition($this->edge);
$angleAndLenght = Geometry2D::getAngleAndLengthFromPoints($center->getX(), $center->getY(), $edge->getX(), $edge->getY());
$length = \round($angleAndLenght['length'] + $this->strokeWeight / 2);
$dImage = Image::newCanvas($image->getWidth(), $image->getHeight());
if ($this->strokeWeight > 0) {
$dImage->drawCircle($center->getX(), $center->getY(), $length * 2, $this->strokeColor);
}
$dImage->drawCircle($center->getX(), $center->getY(), ($length - $this->strokeWeight) * 2, $this->fillColor);
$image->pasteOn($dImage, 0, 0);
return $this;
}
/**
* Get bounding box of the shape
* @return LatLng[]
*/
public function getBoundingBox(): array
{
$distance = GeographicConverter::latLngToMeters($this->center, $this->edge) * 1.4142;
return [
GeographicConverter::metersToLatLng($this->center, $distance, 315),
GeographicConverter::metersToLatLng($this->center, $distance, 135)
];
}
}

View File

@ -1,14 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI\Interfaces;
use DantSu\OpenStreetMapStaticAPI\MapData;
use DantSu\PHPImageEditor\Image;
interface Draw
{
public function getBoundingBox(): array;
public function draw(Image $image, MapData $mapData);
}

View File

@ -1,54 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
/**
* DantSu\OpenStreetMapStaticAPI\LatLng define latitude and longitude for map, lines, markers...
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class LatLng
{
/**
* @var float Latitude
*/
private $lat = 0.0;
/**
* @var float Longitude
*/
private $lng = 0.0;
/**
* LatLng constructor.
* @param float $lat Latitude
* @param float $lng Longitude
*/
public function __construct(float $lat, float $lng)
{
$this->lat = $lat;
$this->lng = $lng;
}
/**
* Get latitude
* @return float Latitude
*/
public function getLat(): float
{
return $this->lat;
}
/**
* Get longitude
* @return float Longitude
*/
public function getLng(): float
{
return $this->lng;
}
}

View File

@ -1,90 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
use DantSu\OpenStreetMapStaticAPI\Interfaces\Draw;
use DantSu\PHPImageEditor\Image;
/**
* DantSu\OpenStreetMapStaticAPI\Line draw line on the map.
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class Line implements Draw
{
/**
* @var string
*/
private $color = '000000';
/**
* @var int
*/
private $weight = 1;
/**
* @var LatLng[]
*/
private $points = [];
/**
* Line constructor.
* @param string $color Hexadecimal string color
* @param int $weight pixel weight of the line
*/
public function __construct(string $color, int $weight)
{
$this->color = \str_replace('#', '', $color);
$this->weight = $weight;
}
/**
* Add a latitude and longitude to the multi-points line
* @param LatLng $latLng Latitude and longitude to add
* @return $this Fluent interface
*/
public function addPoint(LatLng $latLng): Line
{
$this->points[] = $latLng;
return $this;
}
/**
* Draw the line on the map image.
*
* @see https://github.com/DantSu/php-image-editor See more about DantSu\PHPImageEditor\Image
*
* @param Image $image The map image (An instance of DantSu\PHPImageEditor\Image)
* @param MapData $mapData Bounding box of the map
* @return $this Fluent interface
*/
public function draw(Image $image, MapData $mapData): Line
{
/**
* @var $cPoints XY[]
*/
$cPoints = \array_map(
function (LatLng $p) use ($mapData) {
return $mapData->convertLatLngToPxPosition($p);
},
$this->points
);
foreach ($cPoints as $k => $point) {
if (isset($cPoints[$k - 1])) {
$image->drawLine($cPoints[$k - 1]->getX(), $cPoints[$k - 1]->getY(), $point->getX(), $point->getY(), $this->weight, $this->color);
}
}
return $this;
}
/**
* Get bounding box of the shape
* @return LatLng[]
*/
public function getBoundingBox(): array
{
return MapData::getBoundingBoxFromPoints($this->points);
}
}

View File

@ -1,367 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
use DantSu\OpenStreetMapStaticAPI\Utils\GeographicConverter;
/**
* DantSu\OpenStreetMapStaticAPI\MapData convert latitude and longitude to image pixel position.
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class MapData
{
/**
* Convert longitude and zoom to horizontal OpenStreetMap tile number and pixel position.
* @param float $lon Longitude
* @param int $zoom Zoom
* @param int $tileSize Tile size
* @return int[] OpenStreetMap tile id and pixel position of the given longitude and zoom
*/
public static function lngToXTile(float $lon, int $zoom, int $tileSize): array
{
$x = ($lon + 180) / 360 * \pow(2, $zoom);
$tile = \floor($x);
return [
'id' => $tile,
'position' => \round($tileSize * ($x - $tile))
];
}
/**
* Convert latitude and zoom to vertical OpenStreetMap tile number and pixel position.
* @param float $lat Latitude
* @param int $zoom Zoom
* @param int $tileSize Tile size
* @return int[] OpenStreetMap tile id and pixel position of the given latitude and zoom
*/
public static function latToYTile(float $lat, int $zoom, int $tileSize): array
{
$y = (1 - \log(\tan(\deg2rad($lat)) + 1 / \cos(\deg2rad($lat))) / M_PI) / 2 * \pow(2, $zoom);
$tile = \floor($y);
return [
'id' => $tile,
'position' => \round($tileSize * ($y - $tile))
];
}
/**
* Convert horizontal OpenStreetMap tile number ad zoom to longitude.
* @param int $id Horizontal OpenStreetMap tile id
* @param int $position Horizontal pixel position on tile
* @param int $zoom Zoom
* @param int $tileSize Tile size
* @return float Longitude of the given OpenStreetMap tile id and zoom
*/
public static function xTileToLng(int $id, int $position, int $zoom, int $tileSize): float
{
return ($id + $position / $tileSize) / \pow(2, $zoom) * 360 - 180;
}
/**
* Convert vertical OpenStreetMap tile number and zoom to latitude.
* @param int $id Vertical OpenStreetMap tile id
* @param int $position Vertical pixel position on tile
* @param int $zoom Zoom
* @param int $tileSize Tile size
* @return float Latitude of the given OpenStreetMap tile id and zoom
*/
public static function yTileToLat(int $id, int $position, int $zoom, int $tileSize): float
{
return \rad2deg(\atan(\sinh(M_PI * (1 - 2 * ($id + $position / $tileSize) / \pow(2, $zoom)))));
}
/**
* Transform array of LatLng to bounding box
*
* @param LatLng[] $points
* @return LatLng[]
*/
public static function getBoundingBoxFromPoints(array $points): array
{
$minLat = 360;
$maxLat = -360;
$minLng = 360;
$maxLng = -360;
foreach ($points as $point) {
if ($point->getLat() < $minLat) {
$minLat = $point->getLat();
}
if ($point->getLat() > $maxLat) {
$maxLat = $point->getLat();
}
if ($point->getLng() < $minLng) {
$minLng = $point->getLng();
}
if ($point->getLng() > $maxLng) {
$maxLng = $point->getLng();
}
}
return [new LatLng($maxLat, $minLng), new LatLng($minLat, $maxLng)];
}
/**
* Get center and zoom from two points.
*
* @param LatLng $topLeft
* @param LatLng $bottomRight
* @param int $padding
* @param int $imageWidth
* @param int $imageHeight
* @param int $tileSize
* @return array center : LatLng, zoom : int
*/
public static function getCenterAndZoomFromBoundingBox(LatLng $topLeft, LatLng $bottomRight, int $padding, int $imageWidth, int $imageHeight, int $tileSize): array
{
$zoom = 20;
$padding *= 2;
$topTilePos = MapData::latToYTile($topLeft->getLat(), $zoom, $tileSize);
$bottomTilePos = MapData::latToYTile($bottomRight->getLat(), $zoom, $tileSize);
$leftTilePos = MapData::lngToXTile($topLeft->getLng(), $zoom, $tileSize);
$rightTilePos = MapData::lngToXTile($bottomRight->getLng(), $zoom, $tileSize);
$pxZoneWidth = ($rightTilePos['id'] - $leftTilePos['id']) * $tileSize + $rightTilePos['position'] - $leftTilePos['position'];
$pxZoneHeight = ($bottomTilePos['id'] - $topTilePos['id']) * $tileSize + $bottomTilePos['position'] - $topTilePos['position'];
return [
'center' => GeographicConverter::getCenter($topLeft, $bottomRight),
'zoom' => \intval(
\floor(
\log(
\min(
1,
($imageHeight - $padding) / $pxZoneHeight,
($imageWidth - $padding) / $pxZoneWidth
) * \pow(2, $zoom)
) / 0.69314
)
)
];
}
/**
* @var int zoom
*/
private $zoom;
/**
* @var int tile size
*/
private $tileSize;
/**
* @var XY Width and height of the image in pixel
*/
private $outputSize;
/**
* @var XY top left tile numbers
*/
private $tileTopLeft;
/**
* @var XY bottom right tile numbers
*/
private $tileBottomRight;
/**
* @var XY left and top pixels to crop to fit final image size
*/
private $mapCropTopLeft;
/**
* @var XY bottom and right pixels to crop to fit final image size
*/
private $mapCropBottomRight;
/**
* @var LatLng Latitude and longitude of top left image
*/
private $latLngTopLeft;
/**
* @var LatLng Latitude and longitude of top right image
*/
private $latLngTopRight;
/**
* @var LatLng Latitude and longitude of bottom left image
*/
private $latLngBottomLeft;
/**
* @var LatLng Latitude and longitude of bottom right image
*/
private $latLngBottomRight;
/**
* @param LatLng $centerMap
* @param int $zoom
* @param XY $outputSize
* @param int $tileSize
*/
public function __construct(LatLng $centerMap, int $zoom, XY $outputSize, int $tileSize)
{
$this->zoom = $zoom;
$this->outputSize = $outputSize;
$this->tileSize = $tileSize;
$x = static::lngToXTile($centerMap->getLng(), $zoom, $this->tileSize);
$y = static::latToYTile($centerMap->getLat(), $zoom, $this->tileSize);
$startX = \floor($outputSize->getX() / 2 - $x['position']);
$startY = \floor($outputSize->getY() / 2 - $y['position']);
$rightSize = $outputSize->getX() - $startX;
$bottomSize = $outputSize->getY() - $startY;
$this->mapCropTopLeft = new XY(
$startX < 0 ? \abs($startX) : ($startX % $this->tileSize == 0 ? 0 : $this->tileSize - $startX % $this->tileSize),
$startY < 0 ? \abs($startY) : ($startY % $this->tileSize == 0 ? 0 : $this->tileSize - $startY % $this->tileSize)
);
$this->mapCropBottomRight = new XY(
($rightSize % $this->tileSize == 0 ? 0 : $this->tileSize - $rightSize % $this->tileSize),
($bottomSize % $this->tileSize == 0 ? 0 : $this->tileSize - $bottomSize % $this->tileSize)
);
$this->tileTopLeft = new XY(
$x['id'] - \ceil($startX / $this->tileSize),
$y['id'] - \ceil($startY / $this->tileSize)
);
$this->tileBottomRight = new XY(
$x['id'] - 1 + \ceil($rightSize / $this->tileSize),
$y['id'] - 1 + \ceil($bottomSize / $this->tileSize)
);
$this->latLngTopLeft = new LatLng(
static::yTileToLat($this->tileTopLeft->getY(), $this->mapCropTopLeft->getY(), $zoom, $this->tileSize),
static::xTileToLng($this->tileTopLeft->getX(), $this->mapCropTopLeft->getX(), $zoom, $this->tileSize)
);
$this->latLngTopRight = new LatLng(
static::yTileToLat($this->tileTopLeft->getY(), $this->mapCropTopLeft->getY(), $zoom, $this->tileSize),
static::xTileToLng($this->tileBottomRight->getX(), $this->tileSize - $this->mapCropBottomRight->getX(), $zoom, $this->tileSize)
);
$this->latLngBottomLeft = new LatLng(
static::yTileToLat($this->tileBottomRight->getY(), $this->tileSize - $this->mapCropBottomRight->getY(), $zoom, $this->tileSize),
static::xTileToLng($this->tileTopLeft->getX(), $this->mapCropTopLeft->getX(), $zoom, $this->tileSize)
);
$this->latLngBottomRight = new LatLng(
static::yTileToLat($this->tileBottomRight->getY(), $this->tileSize - $this->mapCropBottomRight->getY(), $zoom, $this->tileSize),
static::xTileToLng($this->tileBottomRight->getX(), $this->tileSize - $this->mapCropBottomRight->getX(), $zoom, $this->tileSize)
);
}
/**
* Get latitude and longitude of top left image
* @return LatLng Latitude and longitude of top left image
*/
public function getLatLngTopLeft(): LatLng
{
return $this->latLngTopLeft;
}
/**
* Get latitude and longitude of top right image
* @return LatLng Latitude and longitude of top right image
*/
public function getLatLngTopRight(): LatLng
{
return $this->latLngTopRight;
}
/**
* Get latitude and longitude of bottom left image
* @return LatLng Latitude and longitude of bottom left image
*/
public function getLatLngBottomLeft(): LatLng
{
return $this->latLngBottomLeft;
}
/**
* Get latitude and longitude of bottom right image
* @return LatLng Latitude and longitude of bottom right image
*/
public function getLatLngBottomRight(): LatLng
{
return $this->latLngBottomRight;
}
/**
* Get width and height of the image in pixel
* @return XY Width and height of the image in pixel
*/
public function getOutputSize(): XY
{
return $this->outputSize;
}
/**
* Get the zoom
* @return int zoom
*/
public function getZoom(): int
{
return $this->zoom;
}
/**
* Get tile size
* @return int tile size
*/
public function getTileSize(): int
{
return $this->tileSize;
}
/**
* Get top left tile numbers
* @return XY top left tile numbers
*/
public function getTileTopLeft(): XY
{
return $this->tileTopLeft;
}
/**
* Get bottom right tile numbers
* @return XY bottom right tile numbers
*/
public function getTileBottomRight(): XY
{
return $this->tileBottomRight;
}
/**
* Get top left crop pixels
* @return XY top left crop pixels
*/
public function getMapCropTopLeft(): XY
{
return $this->mapCropTopLeft;
}
/**
* Get bottom right crop pixels
* @return XY bottom right crop pixels
*/
public function getMapCropBottomRight(): XY
{
return $this->mapCropBottomRight;
}
/**
* Convert a latitude and longitude to a XY pixel position in the image
* @param LatLng $latLng Latitude and longitude to be converted
* @return XY Pixel position of latitude and longitude in the image
*/
public function convertLatLngToPxPosition(LatLng $latLng): XY
{
$x = static::lngToXTile($latLng->getLng(), $this->zoom, $this->tileSize);
$y = static::latToYTile($latLng->getLat(), $this->zoom, $this->tileSize);
return new XY(
($x['id'] - $this->tileTopLeft->getX()) * $this->tileSize - $this->mapCropTopLeft->getX() + $x['position'],
($y['id'] - $this->tileTopLeft->getY()) * $this->tileSize - $this->mapCropTopLeft->getY() + $y['position']
);
}
}

View File

@ -1,123 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
use DantSu\PHPImageEditor\Image;
/**
* DantSu\OpenStreetMapStaticAPI\Markers display markers on the map.
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class Markers
{
const ANCHOR_LEFT = 'left';
const ANCHOR_CENTER = 'center';
const ANCHOR_RIGHT = 'right';
const ANCHOR_TOP = 'top';
const ANCHOR_MIDDLE = 'middle';
const ANCHOR_BOTTOM = 'bottom';
/**
* @var Image Image of the marker
*/
private $image;
/**
* @var string|int Horizontal anchor of the marker image
*/
private $horizontalAnchor = Markers::ANCHOR_CENTER;
/**
* @var string|int Vertical anchor of the marker image
*/
private $verticalAnchor = Markers::ANCHOR_MIDDLE;
/**
* @var LatLng[] Latitudes and longitudes of the markers
*/
private $coordinates = [];
public function __construct($pathImage)
{
$this->image = Image::fromPath($pathImage);
}
/**
* Add a marker on the map.
* @param LatLng $coordinate Latitude and longitude of the marker
* @return $this Fluent interface
*/
public function addMarker(LatLng $coordinate): Markers
{
$this->coordinates[] = $coordinate;
return $this;
}
/**
* Define the anchor point of the image marker.
* @param int|string $horizontalAnchor Horizontal anchor in pixel or you can use `Markers::ANCHOR_LEFT`, `Markers::ANCHOR_CENTER`, `Markers::ANCHOR_RIGHT`
* @param int|string $verticalAnchor Vertical anchor in pixel or you can use `Markers::ANCHOR_TOP`, `Markers::ANCHOR_MIDDLE`, `Markers::ANCHOR_BOTTOM`
* @return $this Fluent interface
*/
public function setAnchor($horizontalAnchor, $verticalAnchor): Markers
{
$this->horizontalAnchor = $horizontalAnchor;
$this->verticalAnchor = $verticalAnchor;
return $this;
}
/**
* Draw markers on the image map.
*
* @see https://github.com/DantSu/php-image-editor See more about DantSu\PHPImageEditor\Image
* @param Image $image The map image (An instance of DantSu\PHPImageEditor\Image)
* @param MapData $mapData Bounding box of the map
* @return $this Fluent interface
*/
public function draw(Image $image, MapData $mapData): Markers
{
$imageMarginLeft = $this->horizontalAnchor;
switch ($imageMarginLeft) {
case Markers::ANCHOR_LEFT:
$imageMarginLeft = 0;
break;
case Markers::ANCHOR_CENTER:
$imageMarginLeft = $this->image->getWidth() / 2;
break;
case Markers::ANCHOR_RIGHT:
$imageMarginLeft = $this->image->getWidth();
break;
}
$imageMarginTop = $this->verticalAnchor;
switch ($imageMarginTop) {
case Markers::ANCHOR_TOP:
$imageMarginTop = 0;
break;
case Markers::ANCHOR_MIDDLE:
$imageMarginTop = $this->image->getHeight() / 2;
break;
case Markers::ANCHOR_BOTTOM:
$imageMarginTop = $this->image->getHeight();
break;
}
foreach ($this->coordinates as $coordinate) {
$xy = $mapData->convertLatLngToPxPosition($coordinate);
$image->pasteOn($this->image, $xy->getX() + 1 - $imageMarginLeft, $xy->getY() + 1 - $imageMarginTop);
}
return $this;
}
/**
* Get bounding box of markers
* @return LatLng[]
*/
public function getBoundingBox(): array
{
return MapData::getBoundingBoxFromPoints($this->coordinates);
}
}

View File

@ -1,283 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
use DantSu\OpenStreetMapStaticAPI\Interfaces\Draw;
use DantSu\PHPImageEditor\Image;
/**
* DantSu\OpenStreetMapStaticAPI\OpenStreetMap is a PHP library created for easily get static image from OpenStreetMap with markers, lines, polygons and circles.
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class OpenStreetMap
{
/**
* Create new instance of OpenStreetMap.
* @param LatLng $centerMap Latitude and longitude of the map center
* @param int $zoom Zoom
* @param int $imageWidth Width of the generated map image
* @param int $imageHeight Height of the generated map image
* @param TileLayer $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server
* @param int $tileSize Tile size in pixels
*/
public static function createFromLatLngZoom(LatLng $centerMap, int $zoom, int $imageWidth, int $imageHeight, TileLayer $tileLayer = null, int $tileSize = 256): OpenStreetMap
{
return new OpenStreetMap($centerMap, $zoom, $imageWidth, $imageHeight, $tileLayer, $tileSize);
}
/**
* Create new instance of OpenStreetMap.
* @param LatLng $topLeft Latitude and longitude of the map top left
* @param LatLng $bottomRight Latitude and longitude of the map bottom right
* @param int $padding Padding to add before top left and after bottom right position.
* @param int $imageWidth Width of the generated map image
* @param int $imageHeight Height of the generated map image
* @param TileLayer $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server
* @param int $tileSize Tile size in pixels
* @return OpenStreetMap
*/
public static function createFromBoundingBox(LatLng $topLeft, LatLng $bottomRight, int $padding, int $imageWidth, int $imageHeight, TileLayer $tileLayer = null, int $tileSize = 256): OpenStreetMap
{
if ($tileLayer === null) {
$tileLayer = TileLayer::defaultTileLayer();
}
$latLngZoom = MapData::getCenterAndZoomFromBoundingBox($topLeft, $bottomRight, $padding, $imageWidth, $imageHeight, $tileSize);
return new OpenStreetMap($latLngZoom['center'], $latLngZoom['zoom'], $imageWidth, $imageHeight, $tileLayer, $tileSize);
}
/**
* @var MapData Data about the generated map (bounding box, size, OSM tile ids...)
*/
protected $mapData;
/**
* @var TileLayer[] Array of TileLayer instances
*/
protected $layers = [];
/**
* @var Markers[] Array of Markers instances
*/
protected $markers = [];
/**
* @var Draw[] Array of Line instances
*/
protected $draws = [];
/**
* OpenStreetMap constructor.
* @param LatLng $centerMap Latitude and longitude of the map center
* @param int $zoom Zoom
* @param int $imageWidth Width of the generated map image
* @param int $imageHeight Height of the generated map image
* @param TileLayer $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server
* @param int $tileSize Tile size in pixels
*/
public function __construct(LatLng $centerMap, int $zoom, int $imageWidth, int $imageHeight, TileLayer $tileLayer = null, int $tileSize = 256)
{
if ($tileLayer === null) {
$tileLayer = TileLayer::defaultTileLayer();
}
$this->mapData = new MapData($centerMap, $tileLayer->checkZoom($zoom), new XY($imageWidth, $imageHeight), $tileSize);
$this->layers = [$tileLayer];
}
/**
* Add tile layer to the map
* @param TileLayer $layer An instance of TileLayer
* @return $this Fluent interface
*/
public function addLayer(TileLayer $layer)
{
$this->layers[] = $layer;
return $this;
}
/**
* Add markers on the map
* @param Markers $markers An instance of Markers
* @return $this Fluent interface
*/
public function addMarkers(Markers $markers)
{
$this->markers[] = $markers;
return $this;
}
/**
* Add a line on the map
* @param Draw $draw An instance of Line
* @return $this Fluent interface
*/
public function addDraw(Draw $draw)
{
$this->draws[] = $draw;
return $this;
}
/**
* Fit map to draws.
*
* @param int $padding Padding in pixel
* @return $this Fluent interface
*/
public function fitToDraws(int $padding = 0)
{
$points = [];
foreach ($this->draws as $draw) {
$points = \array_merge($points, $draw->getBoundingBox());
}
return $this->fitToPoints($points, $padding);
}
/**
* Fit map to markers.
*
* @param int $padding Padding in pixel
* @return $this Fluent interface
*/
public function fitToMarkers(int $padding = 0)
{
$points = [];
foreach ($this->markers as $markers) {
$points = \array_merge($points, $markers->getBoundingBox());
}
return $this->fitToPoints($points, $padding);
}
/**
* Fit map to draws and markers.
*
* @param int $padding Padding in pixel
* @return $this Fluent interface
*/
public function fitToMarkersAndDraws(int $padding = 0)
{
$points = [];
foreach ($this->draws as $draw) {
$points = \array_merge($points, $draw->getBoundingBox());
}
foreach ($this->markers as $markers) {
$points = \array_merge($points, $markers->getBoundingBox());
}
return $this->fitToPoints($points, $padding);
}
/**
* Fit map to an array of points.
*
* @param LatLng[] $points LatLng points
* @param int $padding Padding in pixel
* @return $this Fluent interface
*/
public function fitToPoints(array $points, int $padding = 0)
{
$outputSize = $this->mapData->getOutputSize();
$tileSize = $this->mapData->getTileSize();
$boundingBox = MapData::getBoundingBoxFromPoints($points);
$latLngZoom = MapData::getCenterAndZoomFromBoundingBox($boundingBox[0], $boundingBox[1], $padding, $outputSize->getX(), $outputSize->getY(), $tileSize);
$this->mapData = new MapData($latLngZoom['center'], $this->layers[0]->checkZoom($latLngZoom['zoom']), $outputSize, $tileSize);
return $this;
}
/**
* Get data about the generated map (bounding box, size, OSM tile ids...)
* @see https://github.com/DantSu/php-osm-static-api/blob/master/docs/classes/DantSu/OpenStreetMapStaticAPI/MapData.md See more about MapData
* @return MapData data about the generated map (bounding box, size, OSM tile ids...)
*/
public function getMapData(): MapData
{
return $this->mapData;
}
/**
* Get only the map image.
* @see https://github.com/DantSu/php-image-editor See more about DantSu\PHPImageEditor\Image
* @return Image An instance of DantSu\PHPImageEditor\Image
*/
protected function getMapImage(): Image
{
$imgSize = $this->mapData->getOutputSize();
$startX = $this->mapData->getMapCropTopLeft()->getX() * -1;
$startY = $this->mapData->getMapCropTopLeft()->getY() * -1;
$image = Image::newCanvas($imgSize->getX(), $imgSize->getY());
$tileSize = $this->mapData->getTileSize();
foreach ($this->layers as $tileLayer) {
$yTile = $this->mapData->getTileTopLeft()->getY();
for ($y = $startY; $y < $imgSize->getY(); $y += $tileSize) {
$xTile = $this->mapData->getTileTopLeft()->getX();
for ($x = $startX; $x < $imgSize->getX(); $x += $tileSize) {
$image->pasteOn(
$tileLayer->getTile($xTile, $yTile, $this->mapData->getZoom(), $tileSize),
$x,
$y
);
++$xTile;
}
++$yTile;
}
}
return $image;
}
/**
* Draw OpenStreetMap attribution at the right bottom of the image
* @param Image $image The image of the map
* @return Image The image of the map with attribution
*/
protected function drawAttribution(Image $image): Image
{
$margin = 5;
$attribution = function (Image $image, $margin): array {
return $image->writeTextAndGetBoundingBox(
\implode(
' - ',
\array_map(function ($layer) {
return $layer->getAttributionText();
}, $this->layers)
),
__DIR__ . '/resources/font.ttf',
10,
'0078A8',
$margin,
$margin,
Image::ALIGN_LEFT,
Image::ALIGN_TOP
);
};
$bbox = $attribution(Image::newCanvas(1, 1), $margin);
$imageAttribution = Image::newCanvas($bbox['bottom-right']['x'] + $margin, $bbox['bottom-right']['y'] + $margin);
$imageAttribution->drawRectangle(0, 0, $imageAttribution->getWidth(), $imageAttribution->getHeight(), 'FFFFFF33');
$attribution($imageAttribution, $margin);
return $image->pasteOn($imageAttribution, Image::ALIGN_RIGHT, Image::ALIGN_BOTTOM);
}
/**
* Get the map image with markers and lines.
*
* @see https://github.com/DantSu/php-image-editor See more about DantSu\PHPImageEditor\Image
* @return Image An instance of DantSu\PHPImageEditor\Image
*/
public function getImage(): Image
{
$image = $this->getMapImage();
foreach ($this->draws as $line) {
$line->draw($image, $this->mapData);
}
foreach ($this->markers as $markers) {
$markers->draw($image, $this->mapData);
}
return $this->drawAttribution($image);
}
}

View File

@ -1,120 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
use DantSu\OpenStreetMapStaticAPI\Interfaces\Draw;
use DantSu\PHPImageEditor\Image;
/**
* DantSu\OpenStreetMapStaticAPI\Polygon draw polygon on the map.
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class Polygon implements Draw
{
/**
* @var string
*/
private $strokeColor = '000000';
/**
* @var int
*/
private $strokeWeight = 1;
/**
* @var string
*/
private $fillColor = '000000';
/**
* @var LatLng[]
*/
private $points = [];
/**
* Polygon constructor.
* @param string $strokeColor Hexadecimal string color
* @param int $strokeWeight pixel weight of the line
* @param string $fillColor Hexadecimal string color
*/
public function __construct(string $strokeColor, int $strokeWeight, string $fillColor)
{
$this->strokeColor = \str_replace('#', '', $strokeColor);
$this->strokeWeight = $strokeWeight > 0 ? $strokeWeight : 0;
$this->fillColor = \str_replace('#', '', $fillColor);
}
/**
* Add a latitude and longitude to the polygon
* @param LatLng $latLng Latitude and longitude to add
* @return $this Fluent interface
*/
public function addPoint(LatLng $latLng): Polygon
{
$this->points[] = $latLng;
return $this;
}
/**
* Draw the polygon on the map image.
*
* @see https://github.com/DantSu/php-image-editor See more about DantSu\PHPImageEditor\Image
*
* @param Image $image The map image (An instance of DantSu\PHPImageEditor\Image)
* @param MapData $mapData Bounding box of the map
* @return $this Fluent interface
*/
public function draw(Image $image, MapData $mapData): Polygon
{
/**
* @var $cPoints XY[]
*/
$cPoints = \array_map(
function (LatLng $p) use ($mapData) {
return $mapData->convertLatLngToPxPosition($p);
},
$this->points
);
$image->pasteOn(
Image::newCanvas($image->getWidth(), $image->getHeight())
->drawPolygon(
\array_reduce(
$cPoints,
function (array $acc, XY $p) {
$acc[] = $p->getX();
$acc[] = $p->getY();
return $acc;
},
[]
),
$this->fillColor
),
0,
0
);
if ($this->strokeWeight > 0) {
foreach ($cPoints as $k => $point) {
$pK = $k - 1;
if (!isset($cPoints[$pK])) {
$pK = \count($cPoints) - 1;
}
$image->drawLine($cPoints[$pK]->getX(), $cPoints[$pK]->getY(), $point->getX(), $point->getY(), $this->strokeWeight, $this->strokeColor);
}
}
return $this;
}
/**
* Get bounding box of the shape
* @return LatLng[]
*/
public function getBoundingBox(): array
{
return MapData::getBoundingBoxFromPoints($this->points);
}
}

View File

@ -1,206 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
use DantSu\PHPImageEditor\Image;
/**
* DantSu\OpenStreetMapStaticAPI\TileLayer define tile server url and related configuration
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Stephan Strate <hello@stephan.codes>
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class TileLayer
{
/**
* Default tile server. OpenStreetMaps with related attribution text
* @return TileLayer default tile server
*/
public static function defaultTileLayer(): TileLayer
{
return new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', '© OpenStreetMap contributors');
}
/**
* @var string Tile server url, defaults to OpenStreetMap tile server
*/
protected $url;
/**
* @var string Tile server attribution according to license
*/
protected $attributionText;
/**
* @var string[] Tile server subdomains
*/
protected $subdomains;
/**
* @var float Opacity
*/
protected $opacity = 1;
/*
* @var int Max zoom value
*/
protected $maxZoom = 20;
/*
* @var int Min zoom value
*/
protected $minZoom = 0;
/**
* @array $curlOptions Array of curl options
*/
protected $curlOptions = [];
/**
* @bool $failCurlOnError If true, curl will throw an exception on error.
*/
protected $failCurlOnError = false;
/**
* TileLayer constructor
* @param string $url tile server url with placeholders (`x`, `y`, `z`, `r`, `s`)
* @param string $attributionText tile server attribution text
* @param string $subdomains tile server subdomains
* @param array $curlOptions Array of curl options
* @param bool $failCurlOnError If true, curl will throw an exception on error.
*/
public function __construct(string $url, string $attributionText, string $subdomains = 'abc', array $curlOptions = [], bool $failCurlOnError = false)
{
$this->url = $url;
$this->attributionText = $attributionText;
$this->subdomains = \str_split($subdomains);
$this->curlOptions = $curlOptions;
$this->failCurlOnError = $failCurlOnError;
}
/**
* Set opacity of the layer
* @param float $opacity Opacity value (0 to 1)
* @return $this Fluent interface
*/
public function setOpacity(float $opacity)
{
$this->opacity = $opacity;
return $this;
}
/**
* Set a max zoom value
* @param int $maxZoom
* @return $this Fluent interface
*/
public function setMaxZoom(int $maxZoom)
{
$this->maxZoom = $maxZoom;
return $this;
}
/**
* Get max zoom value
* @return int
*/
public function getMaxZoom(): int
{
return $this->maxZoom;
}
/**
* Set a min zoom value
* @param int $minZoom
* @return $this Fluent interface
*/
public function setMinZoom(int $minZoom)
{
$this->minZoom = $minZoom;
return $this;
}
/**
* Get min zoom value
* @return int
*/
public function getMinZoom(): int
{
return $this->minZoom;
}
/**
* Check if zoom value is between min zoom and max zoom
* @param int $zoom Zoom value to be checked
* @return int
*/
public function checkZoom(int $zoom): int
{
return \min(\max($zoom, $this->minZoom), $this->maxZoom);
}
/**
* Get tile url for coordinates and zoom level
* @param int $x x coordinate
* @param int $y y coordinate
* @param int $z zoom level
* @return string tile url
*/
public function getTileUrl(int $x, int $y, int $z): string
{
return \str_replace(
['{r}', '{s}', '{x}', '{y}', '{z}'],
['', $this->getSubdomain($x, $y), $x, $y, $z],
$this->url
);
}
/**
* Select subdomain of tile server to prevent rate limiting on remote server
* @param int $x x coordinate
* @param int $y y coordinate
* @return string selected subdomain
* @see https://github.com/Leaflet/Leaflet/blob/main/src/layer/tile/TileLayer.js#L233 Leaflet implementation
*/
protected function getSubdomain(int $x, int $y): string
{
return $this->subdomains[\abs($x + $y) % \sizeof($this->subdomains)];
}
/**
* Get attribution text
* @return string Attribution text
*/
public function getAttributionText(): string
{
return $this->attributionText;
}
/**
* Get an image tile
* @param float $x
* @param float $y
* @param int $z
* @param int $tileSize
* @return Image Image instance containing the tile
* @throws \Exception
*/
public function getTile(float $x, float $y, int $z, int $tileSize): Image
{
if($this->opacity == 0) {
return Image::newCanvas($tileSize, $tileSize);
}
$tile = Image::fromCurl($this->getTileUrl($x, $y, $z),$this->curlOptions, $this->failCurlOnError);
if($this->opacity > 0 && $this->opacity < 1) {
$tile->setOpacity($this->opacity);
}
return $tile;
}
}

View File

@ -1,101 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI\Utils;
use DantSu\OpenStreetMapStaticAPI\LatLng;
class GeographicConverter
{
/**
* Calculate the earth radius at the given latitude
*
* @param float $lat
* @return float
*/
public static function earthRadiusAtLatitude(float $lat): float
{
$equatorial = 6378137.0;
$pole = 6356752.3;
$lat = \deg2rad($lat);
return \sqrt(
(\pow(\pow($equatorial, 2) * \cos($lat), 2) + \pow(\pow($pole, 2) * \sin($lat), 2)) /
(\pow($equatorial * \cos($lat), 2) + \pow($pole * \sin($lat), 2))
);
}
/**
* Convert distance and angle from a point to latitude and longitude
* 0 : top, 90 : right; 180 : bottom, 270 : left
*
* @param LatLng $from Starting coordinate
* @param float $distance Distance in meters
* @param float $angle Angle in degrees
* @return LatLng
*/
public static function metersToLatLng(LatLng $from, float $distance, float $angle): LatLng
{
$earthRadius = self::earthRadiusAtLatitude($from->getLat());
$lat = \deg2rad($from->getLat());
$lng = \deg2rad($from->getLng());
$angle = \deg2rad($angle);
return new LatLng(
\rad2deg(
\asin(
\sin($lat) * \cos($distance / $earthRadius) +
\cos($lat) * \sin($distance / $earthRadius) * \cos($angle)
)
),
\rad2deg(
$lng + \atan2(
\sin($angle) * \sin($distance / $earthRadius) * \cos($lat),
\cos($distance / $earthRadius) - \sin($lat) * \sin($lat)
)
)
);
}
/**
* Get distance in meters between two points.
*
* @param LatLng $from Starting coordinate
* @param LatLng $end Ending coordinate
* @return float
*/
public static function latLngToMeters(LatLng $from, LatLng $end): float
{
$earthRadius = self::earthRadiusAtLatitude($from->getLat());
$lat1 = \deg2rad($from->getLat());
$lat2 = \deg2rad($end->getLat());
$lat = \deg2rad($end->getLat() - $from->getLat());
$lng = \deg2rad($end->getLng() - $from->getLng());
$a = \pow(\sin($lat / 2), 2) + \cos($lat1) * \cos($lat2) * \pow(\sin($lng / 2), 2);
return \abs($earthRadius * 2 * \atan2(\sqrt($a), \sqrt(1 - $a)));
}
/**
* Get center between two coordinates.
* @param LatLng $point1 Vertical OpenStreetMap tile id
* @param LatLng $point2 Vertical pixel position on tile
* @return LatLng midpoint between the given coordinates
*/
public static function getCenter(LatLng $point1, LatLng $point2): LatLng
{
//return new LatLng(($point1->getLat() + $point2->getLat()) / 2, ($point1->getLng() + $point2->getLng()) / 2);
$dLng = \deg2rad($point2->getLng() - $point1->getLng());
$lat1 = \deg2rad($point1->getLat());
$lat2 = \deg2rad($point2->getLat());
$lng1 = \deg2rad($point1->getLng());
$bx = \cos($lat2) * \cos($dLng);
$by = \cos($lat2) * \sin($dLng);
return new LatLng(
\rad2deg(\atan2(\sin($lat1) + \sin($lat2), \sqrt(\pow(\cos($lat1) + $bx, 2) + \pow($by, 2)))),
\rad2deg($lng1 + \atan2($by, \cos($lat1) + $bx))
);
}
}

View File

@ -1,52 +0,0 @@
<?php
namespace DantSu\OpenStreetMapStaticAPI;
/**
* DantSu\OpenStreetMapStaticAPI\XY define X and Y pixel position for map, lines, markers...
*
* @package DantSu\OpenStreetMapStaticAPI
* @author Franck Alary
* @access public
* @see https://github.com/DantSu/php-osm-static-api Github page of this project
*/
class XY
{
/**
* @var int X
*/
private $x = 0;
/**
* @var int Y
*/
private $y = 0;
/**
* XY constructor.
* @param int $x X
* @param int $y Y
*/
public function __construct(int $x, int $y)
{
$this->x = $x;
$this->y = $y;
}
/**
* Get X
* @return int X
*/
public function getX(): int
{
return $this->x;
}
/**
* Get Y
* @return int Y
*/
public function getY(): int
{
return $this->y;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

View File

@ -1,37 +0,0 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../MapData.php';
require_once '../LatLng.php';
require_once '../Polygon.php';
require_once '../Markers.php';
require_once '../OpenStreetMap.php';
require_once '../XY.php';
use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Polygon;
use \DantSu\OpenStreetMapStaticAPI\Markers;
\header('Content-type: image/png');
OpenStreetMap::createFromBoundingBox(new LatLng(44.352887, 2.565672), new LatLng(44.351172, 2.571092), 10, 600, 400)
->addMarkers(
(new Markers(__DIR__ . '/resources/marker.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
->addMarker(new LatLng(44.351510, 2.570020))
->addMarker(new LatLng(44.351873, 2.566250))
)
->addDraw(
(new Polygon('FF0000', 2, 'FF0000DD'))
->addPoint(new LatLng(44.351172, 2.571092))
->addPoint(new LatLng(44.352097, 2.570045))
->addPoint(new LatLng(44.352665, 2.568107))
->addPoint(new LatLng(44.352887, 2.566503))
->addPoint(new LatLng(44.352806, 2.565972))
->addPoint(new LatLng(44.351517, 2.565672))
)
->getImage()
->displayPNG();

View File

@ -1,90 +0,0 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../MapData.php';
require_once '../LatLng.php';
require_once '../Line.php';
require_once '../Markers.php';
require_once '../OpenStreetMap.php';
require_once '../XY.php';
use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Line;
use \DantSu\OpenStreetMapStaticAPI\Markers;
\header('Content-type: image/png');
(new OpenStreetMap(new LatLng(44.351933, 2.568113), 5, 1024, 1024))
->addMarkers(
(new Markers(__DIR__ . '/resources/marker.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
)
->addMarkers(
(new Markers(__DIR__ . '/resources/marker2.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(48.858535, 2.294107))
->addMarker(new LatLng(52.516304, 13.378107))
->addMarker(new LatLng(40.415176, -3.707362))
->addMarker(new LatLng(51.500845, -0.124591))
->addMarker(new LatLng(41.890145, 12.492552))
->addMarker(new LatLng(36.809764, 10.134114))
->addMarker(new LatLng(31.621758, -7.981512))
->addMarker(new LatLng(47.500469, 19.054086))
->addMarker(new LatLng(28.119083, -15.438387))
->addMarker(new LatLng(57.704334, 11.963886))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(48.858535, 2.294107))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(52.516304, 13.378107))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(40.415176, -3.707362))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(51.500845, -0.124591))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(41.890145, 12.492552))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(36.809764, 10.134114))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(31.621758, -7.981512))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(47.500469, 19.054086))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(28.119083, -15.438387))
)
->addDraw(
(new Line('FF0000', 1))
->addPoint(new LatLng(44.351933, 2.568113))
->addPoint(new LatLng(57.704334, 11.963886))
)
->getImage()
->displayPNG();

View File

@ -1,37 +0,0 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../MapData.php';
require_once '../LatLng.php';
require_once '../Circle.php';
require_once '../Markers.php';
require_once '../OpenStreetMap.php';
require_once '../XY.php';
use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Circle;
use \DantSu\OpenStreetMapStaticAPI\Markers;
\header('Content-type: image/png');
(new OpenStreetMap(new LatLng(0, 0), 0, 600, 400))
->addMarkers(
(new Markers(__DIR__ . '/resources/marker.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
->addMarker(new LatLng(44.351510, 2.570020))
->addMarker(new LatLng(44.351073, 2.566480))
)
->addDraw(
(new Circle(new LatLng(44.351933, 2.568113), 'FF0000', 5, 'FF0000CC'))
->setEdgePoint(new LatLng(44.351510, 2.570020))
)
->addDraw(
(new Circle(new LatLng(44.351933, 2.568113), 'FF0000', 5, 'FF0000CC'))
->setRadius(40)
)
->fitToDraws(10)
->getImage()
->displayPNG();

View File

@ -1,52 +0,0 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../MapData.php';
require_once '../LatLng.php';
require_once '../Polygon.php';
require_once '../Markers.php';
require_once '../OpenStreetMap.php';
require_once '../TileLayer.php';
require_once '../XY.php';
use \DantSu\OpenStreetMapStaticAPI\OpenStreetMap;
use \DantSu\OpenStreetMapStaticAPI\LatLng;
use \DantSu\OpenStreetMapStaticAPI\Polygon;
use \DantSu\OpenStreetMapStaticAPI\Markers;
use \DantSu\OpenStreetMapStaticAPI\TileLayer;
\header('Content-type: image/png');
$tileLayer1 = (new TileLayer(
'https://khms{s}.google.com/kh/v=925?x={x}&y={y}&z={z}',
'Images ©2022 Maxar Technologies',
'0123'
));
// https://stackoverflow.com/a/29712049
$tileLayer2 = (new TileLayer(
'https://mts{s}.google.com/vt/lyrs=h&x={x}&y={y}&z={z}&apistyle=s.t%3A2|p.v%3Aoff',
'©GoogleMaps',
'0123'
))->setOpacity(0.8);
(new OpenStreetMap(new LatLng(44.351933, 2.568113), 17, 600, 400, $tileLayer1))
->addLayer($tileLayer2)
->addMarkers(
(new Markers(__DIR__ . '/resources/marker.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
->addMarker(new LatLng(44.351510, 2.570020))
->addMarker(new LatLng(44.351873, 2.566250))
)
->addDraw(
(new Polygon('FF0000', 2, 'FF0000DD'))
->addPoint(new LatLng(44.351172, 2.571092))
->addPoint(new LatLng(44.352097, 2.570045))
->addPoint(new LatLng(44.352665, 2.568107))
->addPoint(new LatLng(44.352887, 2.566503))
->addPoint(new LatLng(44.352806, 2.565972))
->addPoint(new LatLng(44.351517, 2.565672))
)
->getImage()
->displayPNG();

View File

@ -1,9 +0,0 @@
/vendor/
composer.lock
test.php
.php_cs.cache
.php_cs
.php-cs-fixer.php
.php-cs-fixer.cache
.vscode
.phpunit.cache

View File

@ -1,102 +0,0 @@
<?php
$header = <<<'EOF'
This file is a part of the DiscordPHP-Http project.
Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
This file is subject to the MIT license that is bundled
with this source code in the LICENSE file.
EOF;
$fixers = [
'blank_line_after_namespace',
'braces',
'class_definition',
'elseif',
'encoding',
'full_opening_tag',
'function_declaration',
'lowercase_keywords',
'method_argument_space',
'no_closing_tag',
'no_spaces_after_function_name',
'no_spaces_inside_parenthesis',
'no_trailing_whitespace',
'no_trailing_whitespace_in_comment',
'single_blank_line_at_eof',
'single_class_element_per_statement',
'single_import_per_statement',
'single_line_after_imports',
'switch_case_semicolon_to_colon',
'switch_case_space',
'visibility_required',
'blank_line_after_opening_tag',
'no_multiline_whitespace_around_double_arrow',
'no_empty_statement',
'include',
'no_trailing_comma_in_list_call',
'not_operator_with_successor_space',
'no_leading_namespace_whitespace',
'no_blank_lines_after_class_opening',
'no_blank_lines_after_phpdoc',
'object_operator_without_whitespace',
'binary_operator_spaces',
'phpdoc_indent',
'general_phpdoc_tag_rename',
'phpdoc_inline_tag_normalizer',
'phpdoc_tag_type',
'phpdoc_no_access',
'phpdoc_no_package',
'phpdoc_scalar',
'phpdoc_summary',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_var_without_name',
'no_leading_import_slash',
'no_trailing_comma_in_singleline_array',
'single_blank_line_before_namespace',
'single_quote',
'no_singleline_whitespace_before_semicolons',
'cast_spaces',
'standardize_not_equals',
'ternary_operator_spaces',
'trim_array_spaces',
'unary_operator_spaces',
'no_unused_imports',
'no_useless_else',
'no_useless_return',
'phpdoc_no_empty_return',
'no_extra_blank_lines',
'multiline_whitespace_before_semicolons',
];
$rules = [
'concat_space' => ['spacing' => 'none'],
'phpdoc_no_alias_tag' => ['replacements' => ['type' => 'var']],
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true],
'header_comment' => ['header' => $header],
'indentation_type' => true,
'phpdoc_align' => [
'align' => 'vertical',
'tags' => ['param', 'property', 'property-read', 'property-write', 'return', 'throws', 'type', 'var', 'method'],
],
'blank_line_before_statement' => ['statements' => ['return']],
'constant_case' => ['case' => 'lower'],
'echo_tag_syntax' => ['format' => 'long'],
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
];
foreach ($fixers as $fix) {
$rules[$fix] = true;
}
$config = new PhpCsFixer\Config();
return $config
->setRules($rules)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
);

View File

@ -1,22 +0,0 @@
The MIT License (MIT)
Copyright (c) 2021-present David Cole <david.cole1340@gmail.com> and all
contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,92 +0,0 @@
# DiscordPHP-Http
Asynchronous HTTP client used for communication with the Discord REST API.
## Requirements
- PHP >=7.4
## Installation
```sh
$ composer require discord-php/http
```
A [psr/log](https://packagist.org/packages/psr/log)-compliant logging library is also required. We recommend [monolog](https://github.com/Seldaek/monolog) which will be used in examples.
## Usage
```php
<?php
include 'vendor/autoload.php';
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Discord\Http\Http;
use Discord\Http\Drivers\React;
$loop = \React\EventLoop\Factory::create();
$logger = (new Logger('logger-name'))->pushHandler(new StreamHandler('php://output'));
$http = new Http(
'Bot xxxx.yyyy.zzzz',
$loop,
$logger
);
// set up a driver - this example uses the React driver
$driver = new React($loop);
$http->setDriver($driver);
// must be the last line
$loop->run();
```
All request methods have the same footprint:
```php
$http->get(string $url, $content = null, array $headers = []);
$http->post(string $url, $content = null, array $headers = []);
$http->put(string $url, $content = null, array $headers = []);
$http->patch(string $url, $content = null, array $headers = []);
$http->delete(string $url, $content = null, array $headers = []);
```
For other methods:
```php
$http->queueRequest(string $method, string $url, $content, array $headers = []);
```
All methods return the decoded JSON response in an object:
```php
// https://discord.com/api/v8/oauth2/applications/@me
$http->get('oauth2/applications/@me')->done(function ($response) {
var_dump($response);
}, function ($e) {
echo "Error: ".$e->getMessage().PHP_EOL;
});
```
Most Discord endpoints are provided in the [Endpoint.php](src/Discord/Endpoint.php) class as constants. Parameters start with a colon,
e.g. `channels/:channel_id/messages/:message_id`. You can bind parameters to then with the same class:
```php
// channels/channel_id_here/messages/message_id_here
$endpoint = Endpoint::bind(Endpoint::CHANNEL_MESSAGE, 'channel_id_here', 'message_id_here');
$http->get($endpoint)->done(...);
```
It is recommended that if the endpoint contains parameters you use the `Endpoint::bind()` function to sort requests into their correct rate limit buckets.
For an example, see [DiscordPHP](https://github.com/discord-php/DiscordPHP).
## License
This software is licensed under the MIT license which can be viewed in the [LICENSE](LICENSE) file.
## Credits
- [David Cole](mailto:david.cole1340@gmail.com)
- All contributors

View File

@ -1,43 +0,0 @@
{
"name": "discord-php/http",
"description": "Handles HTTP requests to Discord servers",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "David Cole",
"email": "david.cole1340@gmail.com"
}
],
"autoload": {
"psr-4": {
"Discord\\Http\\": "src/Discord",
"Tests\\Discord\\Http\\": "tests/Discord"
}
},
"require": {
"php": "^7.4|^8.0",
"react/http": "^1.2",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"react/promise": "^2.2 || ^3.0.0"
},
"suggest": {
"guzzlehttp/guzzle": "For alternative to ReactPHP/Http Browser"
},
"require-dev": {
"monolog/monolog": "^2.2",
"friendsofphp/php-cs-fixer": "^2.17",
"psy/psysh": "^0.10.6",
"guzzlehttp/guzzle": "^6.0|^7.0",
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.5",
"react/async": "^4 || ^3"
},
"scripts": {
"test": "php tests/Drivers/_server.php& HTTP_SERVER_PID=$!; ./vendor/bin/phpunit; kill $HTTP_SERVER_PID;",
"test-discord": "./vendor/bin/phpunit --testsuite Discord",
"test-drivers": "php tests/Drivers/_server.php& HTTP_SERVER_PID=$!; ./vendor/bin/phpunit --testsuite Drivers; kill $HTTP_SERVER_PID;",
"test-coverage": "php tests/Drivers/_server.php& HTTP_SERVER_PID=$!; php -d xdebug.mode=coverage ./vendor/bin/phpunit --coverage-text; kill $HTTP_SERVER_PID;",
"test-coverage-html": "php tests/Drivers/_server.php& HTTP_SERVER_PID=$!; php -d xdebug.mode=coverage ./vendor/bin/phpunit --coverage-html .phpunit.cache/cov-html; kill $HTTP_SERVER_PID;"
}
}

View File

@ -1,57 +0,0 @@
<?php
use Discord\Http\Drivers\Guzzle;
use Discord\Http\Endpoint;
use Discord\Http\Http;
use Discord\Http\Multipart\MultipartBody;
use Discord\Http\Multipart\MultipartField;
use Psr\Log\NullLogger;
use React\EventLoop\Loop;
require './vendor/autoload.php';
$http = new Http(
'Your token',
Loop::get(),
new NullLogger(),
new Guzzle(
Loop::get()
)
);
$jsonPayloadField = new MultipartField(
'json_payload',
json_encode([
'content' => 'Hello!',
]),
['Content-Type' => 'application/json']
);
$imageField = new MultipartField(
'files[0]',
file_get_contents('/path/to/image.png'),
['Content-Type' => 'image/png'],
'image.png'
);
$multipart = new MultipartBody([
$jsonPayloadField,
$imageField
]);
$http->post(
Endpoint::bind(
Endpoint::CHANNEL_MESSAGES,
'Channel ID'
),
$multipart
)->then(
function ($response) {
// Do something with response..
},
function (Exception $e) {
echo $e->getMessage(), PHP_EOL;
}
);
Loop::run();

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="Discord">
<directory>tests/Discord</directory>
</testsuite>
<testsuite name="Drivers">
<directory>tests/Drivers</directory>
</testsuite>
</testsuites>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>

View File

@ -1,228 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http;
use Composer\InstalledVersions;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use React\EventLoop\LoopInterface;
use React\EventLoop\TimerInterface;
use SplQueue;
/**
* Represents a rate-limit bucket.
*
* @author David Cole <david.cole1340@gmail.com>
*/
class Bucket
{
/**
* Request queue.
*
* @var SplQueue
*/
protected $queue;
/**
* Bucket name.
*
* @var string
*/
protected $name;
/**
* ReactPHP event loop.
*
* @var LoopInterface
*/
protected $loop;
/**
* HTTP logger.
*
* @var LoggerInterface
*/
protected $logger;
/**
* Callback for when a request is ready.
*
* @var callable
*/
protected $runRequest;
/**
* Whether we are checking the queue.
*
* @var bool
*/
protected $checkerRunning = false;
/**
* Number of requests allowed before reset.
*
* @var int
*/
protected $requestLimit;
/**
* Number of remaining requests before reset.
*
* @var int
*/
protected $requestRemaining;
/**
* Timer to reset the bucket.
*
* @var TimerInterface
*/
protected $resetTimer;
/**
* Whether react/promise v3 is used, if false, using v2
*/
protected $promiseV3 = true;
/**
* Bucket constructor.
*
* @param string $name
* @param callable $runRequest
*/
public function __construct(string $name, LoopInterface $loop, LoggerInterface $logger, callable $runRequest)
{
$this->queue = new SplQueue;
$this->name = $name;
$this->loop = $loop;
$this->logger = $logger;
$this->runRequest = $runRequest;
$this->promiseV3 = str_starts_with(InstalledVersions::getVersion('react/promise'), '3.');
}
/**
* Enqueue a request.
*
* @param Request $request
*/
public function enqueue(Request $request)
{
$this->queue->enqueue($request);
$this->logger->debug($this.' queued '.$request);
$this->checkQueue();
}
/**
* Checks for requests in the bucket.
*/
public function checkQueue()
{
// We are already checking the queue.
if ($this->checkerRunning) {
return;
}
$checkQueue = function () use (&$checkQueue) {
// Check for rate-limits
if ($this->requestRemaining < 1 && ! is_null($this->requestRemaining)) {
$interval = 0;
if ($this->resetTimer) {
$interval = $this->resetTimer->getInterval() ?? 0;
}
$this->logger->info($this.' expecting rate limit, timer interval '.($interval * 1000).' ms');
$this->checkerRunning = false;
$checkQueue = null;
return;
}
// Queue is empty, job done.
if ($this->queue->isEmpty()) {
$this->checkerRunning = false;
$checkQueue = null;
return;
}
/** @var Request */
$request = $this->queue->dequeue();
// Promises v3 changed `->then` to behave as `->done` and removed `->then`. We still need the behaviour of `->done` in projects using v2
($this->runRequest)($request)->{$this->promiseV3 ? 'then' : 'done'}(function (ResponseInterface $response) use (&$checkQueue) {
$resetAfter = (float) $response->getHeaderLine('X-Ratelimit-Reset-After');
$limit = $response->getHeaderLine('X-Ratelimit-Limit');
$remaining = $response->getHeaderLine('X-Ratelimit-Remaining');
if ($resetAfter) {
$resetAfter = (float) $resetAfter;
if ($this->resetTimer) {
$this->loop->cancelTimer($this->resetTimer);
}
$this->resetTimer = $this->loop->addTimer($resetAfter, function () {
// Reset requests remaining and check queue
$this->requestRemaining = $this->requestLimit;
$this->resetTimer = null;
$this->checkQueue();
});
}
// Check if rate-limit headers are present and store
if (is_numeric($limit)) {
$this->requestLimit = (int) $limit;
}
if (is_numeric($remaining)) {
$this->requestRemaining = (int) $remaining;
}
// Check for more requests
$checkQueue();
}, function ($rateLimit) use (&$checkQueue, $request) {
if ($rateLimit instanceof RateLimit) {
$this->queue->enqueue($request);
// Bucket-specific rate-limit
// Re-queue the request and wait the retry after time
if (! $rateLimit->isGlobal()) {
$this->loop->addTimer($rateLimit->getRetryAfter(), $checkQueue);
}
// Stop the queue checker for a global rate-limit.
// Will be restarted when global rate-limit finished.
else {
$this->checkerRunning = false;
$checkQueue = null;
$this->logger->debug($this.' stopping queue checker');
}
} else {
$checkQueue();
}
});
};
$this->checkerRunning = true;
$checkQueue();
}
/**
* Converts a bucket to a user-readable string.
*
* @return string
*/
public function __toString()
{
return 'BUCKET '.$this->name;
}
}

View File

@ -1,34 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http;
use Psr\Http\Message\ResponseInterface;
use React\Promise\PromiseInterface;
/**
* Interface for an HTTP driver.
*
* @author David Cole <david.cole1340@gmail.com>
*/
interface DriverInterface
{
/**
* Runs a request.
*
* Returns a promise resolved with a PSR response interface.
*
* @param Request $request
*
* @return PromiseInterface<ResponseInterface>
*/
public function runRequest(Request $request): PromiseInterface;
}

View File

@ -1,77 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http\Drivers;
use Discord\Http\DriverInterface;
use Discord\Http\Request;
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use React\EventLoop\LoopInterface;
use React\Promise\Deferred;
use React\Promise\PromiseInterface;
/**
* guzzlehttp/guzzle driver for Discord HTTP client. (still with React Promise).
*
* @author SQKo
*/
class Guzzle implements DriverInterface
{
/**
* ReactPHP event loop.
*
* @var LoopInterface|null
*/
protected $loop;
/**
* GuzzleHTTP/Guzzle client.
*
* @var Client
*/
protected $client;
/**
* Constructs the Guzzle driver.
*
* @param LoopInterface|null $loop
* @param array $options
*/
public function __construct(?LoopInterface $loop = null, array $options = [])
{
$this->loop = $loop;
// Allow 400 and 500 HTTP requests to be resolved rather than rejected.
$options['http_errors'] = false;
$this->client = new Client($options);
}
public function runRequest(Request $request): PromiseInterface
{
// Create a React promise
$deferred = new Deferred();
$reactPromise = $deferred->promise();
$promise = $this->client->requestAsync($request->getMethod(), $request->getUrl(), [
RequestOptions::HEADERS => $request->getHeaders(),
RequestOptions::BODY => $request->getContent(),
])->then([$deferred, 'resolve'], [$deferred, 'reject']);
if ($this->loop) {
$this->loop->futureTick([$promise, 'wait']);
} else {
$promise->wait();
}
return $reactPromise;
}
}

View File

@ -1,65 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http\Drivers;
use Discord\Http\DriverInterface;
use Discord\Http\Request;
use React\EventLoop\LoopInterface;
use React\Http\Browser;
use React\Promise\PromiseInterface;
use React\Socket\Connector;
/**
* react/http driver for Discord HTTP client.
*
* @author David Cole <david.cole1340@gmail.com>
*/
class React implements DriverInterface
{
/**
* ReactPHP event loop.
*
* @var LoopInterface
*/
protected $loop;
/**
* ReactPHP/HTTP browser.
*
* @var Browser
*/
protected $browser;
/**
* Constructs the React driver.
*
* @param LoopInterface $loop
* @param array $options
*/
public function __construct(LoopInterface $loop, array $options = [])
{
$this->loop = $loop;
// Allow 400 and 500 HTTP requests to be resolved rather than rejected.
$browser = new Browser($loop, new Connector($loop, $options));
$this->browser = $browser->withRejectErrorResponse(false);
}
public function runRequest(Request $request): PromiseInterface
{
return $this->browser->{$request->getMethod()}(
$request->getUrl(),
$request->getHeaders(),
$request->getContent()
);
}
}

View File

@ -1,449 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http;
class Endpoint
{
// GET
public const GATEWAY = 'gateway';
// GET
public const GATEWAY_BOT = self::GATEWAY.'/bot';
// GET
public const APPLICATION_SKUS = 'applications/:application_id/skus';
// GET, POST
public const APPLICATION_EMOJIS = 'applications/:application_id/emojis';
// GET, PATCH, DELETE
public const APPLICATION_EMOJI = 'applications/:application_id/emojis/:emoji_id';
// GET, POST
public const APPLICATION_ENTITLEMENTS = 'applications/:application_id/entitlements';
// DELETE
public const APPLICATION_ENTITLEMENT = self::APPLICATION_ENTITLEMENTS.'/:entitlement_id';
// POST
public const APPLICATION_ENTITLEMENT_CONSUME = self::APPLICATION_ENTITLEMENT.'/consume';
// GET, POST, PUT
public const GLOBAL_APPLICATION_COMMANDS = 'applications/:application_id/commands';
// GET, PATCH, DELETE
public const GLOBAL_APPLICATION_COMMAND = self::GLOBAL_APPLICATION_COMMANDS.'/:command_id';
// GET, POST, PUT
public const GUILD_APPLICATION_COMMANDS = 'applications/:application_id/guilds/:guild_id/commands';
// GET, PUT
public const GUILD_APPLICATION_COMMANDS_PERMISSIONS = self::GUILD_APPLICATION_COMMANDS.'/permissions';
// GET, PATCH, DELETE
public const GUILD_APPLICATION_COMMAND = self::GUILD_APPLICATION_COMMANDS.'/:command_id';
// GET, PUT
public const GUILD_APPLICATION_COMMAND_PERMISSIONS = self::GUILD_APPLICATION_COMMANDS.'/:command_id/permissions';
// POST
public const INTERACTION_RESPONSE = 'interactions/:interaction_id/:interaction_token/callback';
// POST
public const CREATE_INTERACTION_FOLLOW_UP = 'webhooks/:application_id/:interaction_token';
// PATCH, DELETE
public const ORIGINAL_INTERACTION_RESPONSE = self::CREATE_INTERACTION_FOLLOW_UP.'/messages/@original';
// PATCH, DELETE
public const INTERACTION_FOLLOW_UP = self::CREATE_INTERACTION_FOLLOW_UP.'/messages/:message_id';
// GET
public const SKU_SUBSCRIPTIONS = '/skus/:sku_id/subscriptions';
// GET
public const SKU_SUBSCRIPTION = self::SKU_SUBSCRIPTIONS.'/:subscription_id';
// GET
public const AUDIT_LOG = 'guilds/:guild_id/audit-logs';
// GET, PATCH, DELETE
public const CHANNEL = 'channels/:channel_id';
// GET, POST
public const CHANNEL_MESSAGES = self::CHANNEL.'/messages';
// GET, PATCH, DELETE
public const CHANNEL_MESSAGE = self::CHANNEL.'/messages/:message_id';
// POST
public const CHANNEL_CROSSPOST_MESSAGE = self::CHANNEL.'/messages/:message_id/crosspost';
// POST
public const CHANNEL_MESSAGES_BULK_DELETE = self::CHANNEL.'/messages/bulk-delete';
// PUT, DELETE
public const CHANNEL_PERMISSIONS = self::CHANNEL.'/permissions/:overwrite_id';
// GET, POST
public const CHANNEL_INVITES = self::CHANNEL.'/invites';
// POST
public const CHANNEL_FOLLOW = self::CHANNEL.'/followers';
// POST
public const CHANNEL_TYPING = self::CHANNEL.'/typing';
// GET
public const CHANNEL_PINS = self::CHANNEL.'/pins';
// PUT, DELETE
public const CHANNEL_PIN = self::CHANNEL.'/pins/:message_id';
// POST
public const CHANNEL_THREADS = self::CHANNEL.'/threads';
// POST
public const CHANNEL_MESSAGE_THREADS = self::CHANNEL_MESSAGE.'/threads';
// GET
public const CHANNEL_THREADS_ARCHIVED_PUBLIC = self::CHANNEL_THREADS.'/archived/public';
// GET
public const CHANNEL_THREADS_ARCHIVED_PRIVATE = self::CHANNEL_THREADS.'/archived/private';
// GET
public const CHANNEL_THREADS_ARCHIVED_PRIVATE_ME = self::CHANNEL.'/users/@me/threads/archived/private';
// POST
public const CHANNEL_SEND_SOUNDBOARD_SOUND = self::CHANNEL . '/send-soundboard-sound';
// GET, PATCH, DELETE
public const THREAD = 'channels/:thread_id';
// GET
public const THREAD_MEMBERS = self::THREAD.'/thread-members';
// GET, PUT, DELETE
public const THREAD_MEMBER = self::THREAD_MEMBERS.'/:user_id';
// PUT, DELETE
public const THREAD_MEMBER_ME = self::THREAD_MEMBERS.'/@me';
// GET, DELETE
public const MESSAGE_REACTION_ALL = self::CHANNEL.'/messages/:message_id/reactions';
// GET, DELETE
public const MESSAGE_REACTION_EMOJI = self::CHANNEL.'/messages/:message_id/reactions/:emoji';
// PUT, DELETE
public const OWN_MESSAGE_REACTION = self::CHANNEL.'/messages/:message_id/reactions/:emoji/@me';
// DELETE
public const USER_MESSAGE_REACTION = self::CHANNEL.'/messages/:message_id/reactions/:emoji/:user_id';
// GET
protected const MESSAGE_POLL = self::CHANNEL.'/polls/:message_id';
// GET
public const MESSAGE_POLL_ANSWER = self::MESSAGE_POLL.'/answers/:answer_id';
// POST
public const MESSAGE_POLL_EXPIRE = self::MESSAGE_POLL.'/expire';
// GET, POST
public const CHANNEL_WEBHOOKS = self::CHANNEL.'/webhooks';
// POST
public const GUILDS = 'guilds';
// GET, PATCH, DELETE
public const GUILD = 'guilds/:guild_id';
// GET, POST, PATCH
public const GUILD_CHANNELS = self::GUILD.'/channels';
// GET
public const GUILD_THREADS_ACTIVE = self::GUILD.'/threads/active';
// GET
public const GUILD_MEMBERS = self::GUILD.'/members';
// GET
public const GUILD_MEMBERS_SEARCH = self::GUILD.'/members/search';
// GET, PATCH, PUT, DELETE
public const GUILD_MEMBER = self::GUILD.'/members/:user_id';
// PATCH
public const GUILD_MEMBER_SELF = self::GUILD.'/members/@me';
/** @deprecated 9.0.9 Use `GUILD_MEMBER_SELF` */
public const GUILD_MEMBER_SELF_NICK = self::GUILD.'/members/@me/nick';
// PUT, DELETE
public const GUILD_MEMBER_ROLE = self::GUILD.'/members/:user_id/roles/:role_id';
// GET
public const GUILD_BANS = self::GUILD.'/bans';
// GET, PUT, DELETE
public const GUILD_BAN = self::GUILD.'/bans/:user_id';
// GET, PATCH
public const GUILD_ROLES = self::GUILD.'/roles';
// GET, POST, PATCH, DELETE
public const GUILD_ROLE = self::GUILD.'/roles/:role_id';
// POST
public const GUILD_MFA = self::GUILD.'/mfa';
// GET, POST
public const GUILD_INVITES = self::GUILD.'/invites';
// GET, POST
public const GUILD_INTEGRATIONS = self::GUILD.'/integrations';
// PATCH, DELETE
public const GUILD_INTEGRATION = self::GUILD.'/integrations/:integration_id';
// POST
public const GUILD_INTEGRATION_SYNC = self::GUILD.'/integrations/:integration_id/sync';
// GET, POST
public const GUILD_EMOJIS = self::GUILD.'/emojis';
// GET, PATCH, DELETE
public const GUILD_EMOJI = self::GUILD.'/emojis/:emoji_id';
// GET
public const GUILD_PREVIEW = self::GUILD.'/preview';
// GET, POST
public const GUILD_PRUNE = self::GUILD.'/prune';
// GET
public const GUILD_REGIONS = self::GUILD.'/regions';
// GET, PATCH
public const GUILD_WIDGET_SETTINGS = self::GUILD.'/widget';
// GET
public const GUILD_WIDGET = self::GUILD.'/widget.json';
// GET
public const GUILD_WIDGET_IMAGE = self::GUILD.'/widget.png';
// GET, PATCH
public const GUILD_WELCOME_SCREEN = self::GUILD.'/welcome-screen';
// GET
public const GUILD_ONBOARDING = self::GUILD.'/onboarding';
// GET, PATCH
public const GUILD_USER_CURRENT_VOICE_STATE = self::GUILD.'/voice-states/@me';
// GET, PATCH
public const GUILD_USER_VOICE_STATE = self::GUILD.'/voice-states/:user_id';
// GET
public const GUILD_VANITY_URL = self::GUILD.'/vanity-url';
// GET, PATCH
public const GUILD_MEMBERSHIP_SCREENING = self::GUILD.'/member-verification';
// GET
public const GUILD_WEBHOOKS = self::GUILD.'/webhooks';
// GET, POST
public const GUILD_STICKERS = self::GUILD.'/stickers';
// GET, PATCH, DELETE
public const GUILD_STICKER = self::GUILD.'/stickers/:sticker_id';
// GET
public const STICKER = 'stickers/:sticker_id';
// GET
public const STICKER_PACKS = 'sticker-packs';
// GET, POST
public const GUILD_SCHEDULED_EVENTS = self::GUILD.'/scheduled-events';
// GET, PATCH, DELETE
public const GUILD_SCHEDULED_EVENT = self::GUILD.'/scheduled-events/:guild_scheduled_event_id';
// GET
public const GUILD_SCHEDULED_EVENT_USERS = self::GUILD.'/scheduled-events/:guild_scheduled_event_id/users';
// GET, POST
public const GUILD_SOUNDBOARD_SOUNDS = self::GUILD.'/soundboard-sounds';
// GET, PATCH, DELETE
public const GUILD_SOUNDBOARD_SOUND = self::GUILD.'/soundboard-sounds/:sound_id';
// GET, DELETE
public const INVITE = 'invites/:code';
// POST
public const STAGE_INSTANCES = 'stage-instances';
// GET, PATCH, DELETE
public const STAGE_INSTANCE = 'stage-instances/:channel_id';
// GET, POST
public const GUILDS_TEMPLATE = self::GUILDS.'/templates/:template_code';
// GET, POST
public const GUILD_TEMPLATES = self::GUILD.'/templates';
// PUT, PATCH, DELETE
public const GUILD_TEMPLATE = self::GUILD.'/templates/:template_code';
// GET, POST
public const GUILD_AUTO_MODERATION_RULES = self::GUILD.'/auto-moderation/rules';
// GET, PATCH, DELETE
public const GUILD_AUTO_MODERATION_RULE = self::GUILD.'/auto-moderation/rules/:auto_moderation_rule_id';
// GET
public const SOUNDBOARD_DEFAULT_SOUNDS = 'soundboard-default-sounds';
// GET, PATCH
public const USER_CURRENT = 'users/@me';
// GET
public const USER = 'users/:user_id';
// GET
public const USER_CURRENT_GUILDS = self::USER_CURRENT.'/guilds';
// DELETE
public const USER_CURRENT_GUILD = self::USER_CURRENT.'/guilds/:guild_id';
// GET
public const USER_CURRENT_MEMBER = self::USER_CURRENT.'/guilds/:guild_id/member';
// GET, POST
public const USER_CURRENT_CHANNELS = self::USER_CURRENT.'/channels';
// GET
public const USER_CURRENT_CONNECTIONS = self::USER_CURRENT.'/connections';
// GET, PUT
public const USER_CURRENT_APPLICATION_ROLE_CONNECTION = self::USER_CURRENT.'/applications/:application_id/role-connection';
// GET
public const APPLICATION_CURRENT = 'applications/@me';
// GET, PATCH, DELETE
public const WEBHOOK = 'webhooks/:webhook_id';
// GET, PATCH, DELETE
public const WEBHOOK_TOKEN = 'webhooks/:webhook_id/:webhook_token';
// POST
public const WEBHOOK_EXECUTE = self::WEBHOOK_TOKEN;
// POST
public const WEBHOOK_EXECUTE_SLACK = self::WEBHOOK_EXECUTE.'/slack';
// POST
public const WEBHOOK_EXECUTE_GITHUB = self::WEBHOOK_EXECUTE.'/github';
// PATCH, DELETE
public const WEBHOOK_MESSAGE = self::WEBHOOK_TOKEN.'/messages/:message_id';
// GET, PUT
public const APPLICATION_ROLE_CONNECTION_METADATA = 'applications/:application_id/role-connections/metadata';
/**
* Regex to identify parameters in endpoints.
*
* @var string
*/
public const REGEX = '/:([^\/]*)/';
/**
* A list of parameters considered 'major' by Discord.
*
* @see https://discord.com/developers/docs/topics/rate-limits
* @var string[]
*/
public const MAJOR_PARAMETERS = ['channel_id', 'guild_id', 'webhook_id', 'thread_id'];
/**
* The string version of the endpoint, including all parameters.
*
* @var string
*/
protected $endpoint;
/**
* Array of placeholders to be replaced in the endpoint.
*
* @var string[]
*/
protected $vars = [];
/**
* Array of arguments to substitute into the endpoint.
*
* @var string[]
*/
protected $args = [];
/**
* Array of query data to be appended
* to the end of the endpoint with `http_build_query`.
*
* @var array
*/
protected $query = [];
/**
* Creates an endpoint class.
*
* @param string $endpoint
*/
public function __construct(string $endpoint)
{
$this->endpoint = $endpoint;
if (preg_match_all(self::REGEX, $endpoint, $vars)) {
$this->vars = $vars[1] ?? [];
}
}
/**
* Binds a list of arguments to the endpoint.
*
* @param string[] ...$args
* @return this
*/
public function bindArgs(...$args): self
{
for ($i = 0; $i < count($this->vars) && $i < count($args); $i++) {
$this->args[$this->vars[$i]] = $args[$i];
}
return $this;
}
/**
* Binds an associative array to the endpoint.
*
* @param string[] $args
* @return this
*/
public function bindAssoc(array $args): self
{
$this->args = array_merge($this->args, $args);
return $this;
}
/**
* Adds a key-value query pair to the endpoint.
*
* @param string $key
* @param string|bool $value
*/
public function addQuery(string $key, $value): void
{
if (! is_bool($value)) {
$value = (string) $value;
}
$this->query[$key] = $value;
}
/**
* Converts the endpoint into the absolute endpoint with
* placeholders replaced.
*
* Passing a true boolean in will only replace the major parameters.
* Used for rate limit buckets.
*
* @param bool $onlyMajorParameters
* @return string
*/
public function toAbsoluteEndpoint(bool $onlyMajorParameters = false): string
{
$endpoint = $this->endpoint;
foreach ($this->vars as $var) {
if (! isset($this->args[$var]) || ($onlyMajorParameters && ! $this->isMajorParameter($var))) {
continue;
}
$endpoint = str_replace(":{$var}", $this->args[$var], $endpoint);
}
if (! $onlyMajorParameters && count($this->query) > 0) {
$endpoint .= '?'.http_build_query($this->query);
}
return $endpoint;
}
/**
* Converts the endpoint to a string.
* Alias of ->toAbsoluteEndpoint();.
*
* @return string
*/
public function __toString(): string
{
return $this->toAbsoluteEndpoint();
}
/**
* Creates an endpoint class and binds arguments to
* the newly created instance.
*
* @param string $endpoint
* @param string[] $args
* @return Endpoint
*/
public static function bind(string $endpoint, ...$args)
{
$endpoint = new Endpoint($endpoint);
$endpoint->bindArgs(...$args);
return $endpoint;
}
/**
* Checks if a parameter is a major parameter.
*
* @param string $param
* @return bool
*/
private static function isMajorParameter(string $param): bool
{
return in_array($param, self::MAJOR_PARAMETERS);
}
}

View File

@ -1,22 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http\Exceptions;
/**
* Thrown when a request to Discord's REST API returned ClientErrorResponse.
*
* @author SQKo
*/
class BadRequestException extends RequestFailedException
{
protected $code = 400;
}

View File

@ -1,22 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http\Exceptions;
/**
* Thrown when the Discord servers return `content longer than 2000 characters` after
* a REST request. The user must use WebSockets to obtain this data if they need it.
*
* @author David Cole <david.cole1340@gmail.com>
*/
class ContentTooLongException extends RequestFailedException
{
}

View File

@ -1,22 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http\Exceptions;
/**
* Thrown when an invalid token is provided to a Discord endpoint.
*
* @author David Cole <david.cole1340@gmail.com>
*/
class InvalidTokenException extends RequestFailedException
{
protected $code = 401;
}

View File

@ -1,22 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http\Exceptions;
/**
* Thrown when a request to Discord's REST API method is invalid.
*
* @author SQKo
*/
class MethodNotAllowedException extends RequestFailedException
{
protected $code = 405;
}

View File

@ -1,22 +0,0 @@
<?php
/*
* This file is a part of the DiscordPHP-Http project.
*
* Copyright (c) 2021-present David Cole <david.cole1340@gmail.com>
*
* This file is subject to the MIT license that is bundled
* with this source code in the LICENSE file.
*/
namespace Discord\Http\Exceptions;
/**
* Thrown when you do not have permissions to do something.
*
* @author David Cole <david.cole1340@gmail.com>
*/
class NoPermissionsException extends RequestFailedException
{
protected $code = 403;
}

Some files were not shown because too many files have changed in this diff Show More