Skip to content

Commit

Permalink
Remove laravel support
Browse files Browse the repository at this point in the history
  • Loading branch information
punyflash committed Aug 15, 2023
1 parent 97730d0 commit 05c988c
Show file tree
Hide file tree
Showing 32 changed files with 75 additions and 1,419 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/vendor/
composer.lock
.phpunit.result.cache
/.phpunit.cache
.php_cs.cache
phpunit.xml
/build/
Expand Down
13 changes: 0 additions & 13 deletions _ide_helpers.php

This file was deleted.

8 changes: 3 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
],
"require": {
"php": "^8.0",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0"
"guzzlehttp/guzzle": "^6.0 || ^7.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"orchestra/testbench": "^3.5 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
"phpunit/phpunit": "^8.0 || ^9.0",
"rector/rector": "^0.15.21"
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0",
"rector/rector": "^0.17"
},
"autoload": {
"psr-4": {
Expand Down
32 changes: 10 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false" backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" backupGlobals="false"
colors="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml" />
<html outputDirectory="build/coverage" />
<text outputFile="build/coverage.txt" />
</report>
</coverage>

<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
Expand All @@ -33,7 +18,10 @@
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>

<logging />

<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
44 changes: 41 additions & 3 deletions src/Contracts/TelegramObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace WeStacks\TeleBot\Contracts;

use ArrayIterator;
use Illuminate\Support\Arr;
use IteratorAggregate;
use JsonSerializable;
use Traversable;
Expand Down Expand Up @@ -127,7 +126,7 @@ public function get($key, mixed $default = null)
return $this->getMany($key);
}

return Arr::get($this->toArray(), $key, $default);
return $this->_get($this->toArray(), $key, $default);
}

private function getMany($keys)
Expand All @@ -139,12 +138,51 @@ private function getMany($keys)
[$key, $default] = [$default, null];
}

$data[$key] = Arr::get($this->items, $key, $default);
$data[$key] = $this->_get($this->items, $key, $default);
}

return $data;
}

private function value($value, ...$args)
{
return $value instanceof \Closure ? $value(...$args) : $value;
}

private function accessible($array)
{
return is_array($array) || $array instanceof \ArrayAccess;
}

private function _get($array, $key, $default = null)
{
if (! $this->accessible($array)) {
return $this->value($array);
}

if (is_null($key)) {
return $array;
}

if (array_key_exists($key, $array)) {
return $array[$key];
}

if (! str_contains($key, '.')) {
return $array[$key] ?? $this->value($default);
}

foreach (explode('.', $key) as $segment) {
if ($this->accessible($array) && array_key_exists($segment, $array)) {
$array = $array[$segment];
} else {
return $this->value($default);
}
}

return $array;
}

public function getIterator(): Traversable
{
return new ArrayIterator($this->properties);
Expand Down
5 changes: 1 addition & 4 deletions src/Handlers/CommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ abstract class CommandHandler extends UpdateHandler
*/
final public static function getBotCommand(?string $locale = null)
{
$description = rescue(
fn () => trans(static::$description, locale: $locale),
static::$description, false
);
$description = function_exists('trans') ? trans(static::$description, locale: $locale) : static::$description;

return array_map(
function (string $command) use ($description) {
Expand Down
102 changes: 0 additions & 102 deletions src/Laravel/Artisan/CommandsCommand.php

This file was deleted.

89 changes: 0 additions & 89 deletions src/Laravel/Artisan/LongPollCommad.php

This file was deleted.

Loading

0 comments on commit 05c988c

Please sign in to comment.