profile
viewpoint

discord-php/DiscordPHP 851

An API to interact with the popular messaging app Discord

dc-Ragnarok/Fenrir 3

PHP Discord Interface

Exanlv/DHP 1

Discord Helper PHP

dc-Ragnarok/Lyngvi 0

Bot to monitor stability of Fenrir

Exanlv/.env-reader 0

.env processor

Exanlv/backup 0

a thing for backups

Exanlv/Bread 0

Bread

Exanlv/CatBot 0

Discord bot that sends a cat

PullRequestReviewEvent

push eventtnapf/Config

Exanlv

commit sha 53785c237c3b2eaa563fcb62ef038c247790b2c1

Rename function

view details

push time in 8 hours

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commenttnapf/Config

feature/cached-config-provider

 public function testItThrowsAnErrorIfAConfigProviderReturnsNonArrayForMultiLevel      */     public function testItReturnsDefault(string $key, mixed $providerReturn)     {-        /** @var ConfigProvider&MockInterface */+        /** @var ConfigProvider&MockInterface $configProvider */

https://discord.com/channels/1040758519323971624/1103456136671268884/1113826503038353478

freezemage0

comment created time in 9 hours

push eventdc-Ragnarok/Fenrir

Exanlv

commit sha df49d77f07d8a9c69f947345222cbb26af976e48

Add binding

view details

push time in a day

created tagdc-Ragnarok/Fenrir

tag0.6.2

PHP Discord Interface

created time in a day

release dc-Ragnarok/Fenrir

0.6.2

released time in a day

push eventdc-Ragnarok/Fenrir

Exanlv

commit sha ec37405fbaeee9329843b86eb45ccc11fbe5f57b

Api updates

view details

Exanlv

commit sha 14067258e84f41774c3bac204490ed13f4a7abb0

Merge pull request #42 from dc-Ragnarok/chore/api-updates-may-2023 Api updates

view details

push time in a day

PR merged dc-Ragnarok/Fenrir

Api updates
  • Add Auto Moderation custom_message Action Metadata Field https://discord.com/developers/docs/change-log#add-auto-moderation-custommessage-action-metadata-field

  • Interaction Channel Data https://discord.com/developers/docs/change-log#interaction-channel-data

  • Add Join Raid and Mention Raid fields https://discord.com/developers/docs/change-log#add-join-raid-and-mention-raid-fields

+11 -2

0 comment

4 changed files

Exanlv

pr closed time in a day

push eventdc-Ragnarok/Fenrir

Exanlv

commit sha ddd780d6e219c44fddb6ead8a8073f465e4ae515

Add bindings

view details

push time in 2 days

push eventExanlv/tnapf-JsonMapper

Exanlv

commit sha a586f54ea055fa1554333a14b60d3f5decf9b58c

cs

view details

push time in 2 days

PR opened tnapf/JsonMapper

Feat: add enum support

Added enums, made some small changes

+346 -816

0 comment

34 changed files

pr created time in 2 days

create barnchExanlv/tnapf-JsonMapper

branch : feat/add-enum

created branch time in 2 days

push eventdc-Ragnarok/Fenrir

Exanlv

commit sha f1fe64cbe33bac936832588d768295e7f9d12fff

More guild bindings

view details

push time in 2 days

PR opened dc-Ragnarok/Fenrir

Api updates
  • Add Auto Moderation custom_message Action Metadata Field https://discord.com/developers/docs/change-log#add-auto-moderation-custommessage-action-metadata-field

  • Interaction Channel Data https://discord.com/developers/docs/change-log#interaction-channel-data

  • Add Join Raid and Mention Raid fields https://discord.com/developers/docs/change-log#add-join-raid-and-mention-raid-fields

+11 -2

0 comment

4 changed files

pr created time in 3 days

push eventdc-Ragnarok/Fenrir

Exanlv

commit sha ec37405fbaeee9329843b86eb45ccc11fbe5f57b

Api updates

view details

push time in 3 days

create barnchdc-Ragnarok/Fenrir

branch : chore/api-updates-may-2023

created branch time in 3 days

push eventdc-Ragnarok/Fenrir

Exanlv

commit sha 5f5e186ea9641b9be8011adfcc70f2621278e820

Add more bindings

view details

push time in 3 days

Pull request review commenttnapf/Config

feature/cached-config-provider

+<?php++namespace Tnapf\Config\Cache;++use DateInterval;+use Psr\SimpleCache\CacheInterface;+use Psr\SimpleCache\InvalidArgumentException;+use Tnapf\Config\Exceptions\InvalidCacheKeyException;++class InMemoryDriver implements CacheInterface+{+    private array $storage = [];++    /**+     * @throws InvalidArgumentException+     */+    public function get(string $key, mixed $default = null): mixed+    {+        return $this->has($key) ? $this->storage[$key] : $default;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool+    {+        $this->validateKey($key);+        $this->storage[$key] = $value;++        return true;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function delete(string $key): bool+    {+        $this->validateKey($key);+        unset($this->storage[$key]);++        return true;+    }++    public function clear(): bool+    {+        $this->storage = [];++        return true;+    }++    /**+     * @param string[] $keys+     *+     * @throws InvalidArgumentException+     *+     * @return iterable<string, mixed>+     */+    public function getMultiple(iterable $keys, mixed $default = null): iterable+    {+        $items = [];+        foreach ($keys as $key) {+            $items[$key] = $this->get($key, $default);+        }++        return $items;+    }++    /**+     * @throws InvalidArgumentException+     */+    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool+    {+        foreach ($values as $key => $value) {

It's ever so slightly faster to do it with my suggestion and a separate loop for validating keys. But its ~0.01 to 0.03 seconds faster for every million uses so not worth it

freezemage0

comment created time in 3 days

PullRequestReviewEvent

Pull request review commenttnapf/Config

feature/cached-config-provider

+<?php++namespace Tnapf\Config\Test\Cache;++use PHPUnit\Framework\TestCase;+use Tnapf\Config\Cache\InMemoryDriver;+use Tnapf\Config\Exceptions\InvalidCacheKeyException;++class InMemoryDriverTest extends TestCase+{+    public function testItCachesValues(): void+    {+        $driver = new InMemoryDriver();+        $driver->set('host', 'localhost');++        $this->assertTrue($driver->has('host'));+        $this->assertSame('localhost', $driver->get('host'));+    }++    public function testItDeletesCache(): void+    {+        $driver = new InMemoryDriver();+        $driver->set('key', 'value');++        $driver->delete('key');++        $this->assertFalse($driver->has('key'));+        $this->assertNull($driver->get('key'));+    }++    public function testItClearsCache(): void+    {+        $driver = new InMemoryDriver();+        $driver->setMultiple(['host' => 'localhost', 'user' => 'root']);++        $driver->clear();++        $this->assertFalse($driver->has('host'));+        $this->assertNull($driver->get('host'));++        $this->assertFalse($driver->has('user'));+        $this->assertNull($driver->get('user'));+    }++    public function testItRetrievesDefaultValueOnMissingCache(): void+    {+        $driver = new InMemoryDriver();++        $this->assertFalse($driver->has('non-existent-key'));++        $result = $driver->get('non-existent-key', 'defaultValue');+        $this->assertSame('defaultValue', $result);+    }++    public function testItFillsDefaultValueForMultipleKeys(): void+    {+        $driver = new InMemoryDriver();++        $driver->set('host', 'localhost');+        $expected = ['host' => 'localhost', 'user' => 'empty', 'driver' => 'empty'];++        $this->assertSame($expected, $driver->getMultiple(['host', 'user', 'driver'], 'empty'));+    }++    public function testItDeletesMultipleKeys(): void+    {+        $driver = new InMemoryDriver();++        $driver->setMultiple(['host' => 'localhost', 'user' => 'root', 'driver' => 'pdo']);++        $driver->deleteMultiple(['host', 'user']);++        $this->assertFalse($driver->has('host'));+        $this->assertNull($driver->get('host'));++        $this->assertFalse($driver->has('user'));+        $this->assertNull($driver->get('user'));++        $this->assertTrue($driver->has('driver'));+        $this->assertSame('pdo', $driver->get('driver'));+    }++    public function testItThrowsWhenCacheKeyIsInvalid(): void+    {+        $this->expectException(InvalidCacheKeyException::class);++        $driver = new InMemoryDriver();+        $driver->get('{invalid}');

Since there's a lot of characters that are not allowed, how about a dataprovider that provides every one of those chars separately which is then prepended to some string to be tested?

freezemage0

comment created time in 3 days

PullRequestReviewEvent

Pull request review commenttnapf/Config

feature/cached-config-provider

+<?php++namespace Tnapf\Config\Cache;++use DateInterval;+use Psr\SimpleCache\CacheInterface;+use Psr\SimpleCache\InvalidArgumentException;+use Tnapf\Config\Exceptions\InvalidCacheKeyException;++class InMemoryDriver implements CacheInterface+{+    private array $storage = [];++    /**+     * @throws InvalidArgumentException+     */+    public function get(string $key, mixed $default = null): mixed+    {+        return $this->has($key) ? $this->storage[$key] : $default;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool+    {+        $this->validateKey($key);+        $this->storage[$key] = $value;++        return true;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function delete(string $key): bool+    {+        $this->validateKey($key);+        unset($this->storage[$key]);++        return true;+    }++    public function clear(): bool+    {+        $this->storage = [];++        return true;+    }++    /**+     * @param string[] $keys+     *+     * @throws InvalidArgumentException+     *+     * @return iterable<string, mixed>+     */+    public function getMultiple(iterable $keys, mixed $default = null): iterable+    {+        $items = [];+        foreach ($keys as $key) {+            $items[$key] = $this->get($key, $default);+        }++        return $items;+    }++    /**+     * @throws InvalidArgumentException+     */+    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool+    {+        foreach ($values as $key => $value) {

Maybe a bit jank, but would this work?

$this->storage = [...$this->storage, ...$values];

Guessing no, cuz of iterable instead of array

freezemage0

comment created time in 3 days

PullRequestReviewEvent

Pull request review commenttnapf/Config

feature/cached-config-provider

+<?php++namespace Tnapf\Config\Cache;++use DateInterval;+use Psr\SimpleCache\CacheInterface;+use Psr\SimpleCache\InvalidArgumentException;+use Tnapf\Config\Exceptions\InvalidCacheKeyException;++class InMemoryDriver implements CacheInterface+{+    private array $storage = [];++    /**+     * @throws InvalidArgumentException+     */+    public function get(string $key, mixed $default = null): mixed+    {+        return $this->has($key) ? $this->storage[$key] : $default;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool+    {+        $this->validateKey($key);+        $this->storage[$key] = $value;++        return true;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function delete(string $key): bool+    {+        $this->validateKey($key);+        unset($this->storage[$key]);++        return true;+    }++    public function clear(): bool+    {+        $this->storage = [];++        return true;+    }++    /**+     * @param string[] $keys+     *+     * @throws InvalidArgumentException+     *+     * @return iterable<string, mixed>+     */+    public function getMultiple(iterable $keys, mixed $default = null): iterable+    {+        $items = [];+        foreach ($keys as $key) {+            $items[$key] = $this->get($key, $default);+        }++        return $items;+    }++    /**+     * @throws InvalidArgumentException+     */+    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool+    {+        foreach ($values as $key => $value) {+            $this->set($key, $value, $ttl);+        }++        return true;+    }++    /**+     * @throws InvalidArgumentException
     * @throws InvalidCacheKeyException
freezemage0

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commenttnapf/Config

feature/cached-config-provider

+<?php++namespace Tnapf\Config\Cache;++use DateInterval;+use Psr\SimpleCache\CacheInterface;+use Psr\SimpleCache\InvalidArgumentException;+use Tnapf\Config\Exceptions\InvalidCacheKeyException;++class InMemoryDriver implements CacheInterface+{+    private array $storage = [];++    /**+     * @throws InvalidArgumentException+     */+    public function get(string $key, mixed $default = null): mixed+    {+        return $this->has($key) ? $this->storage[$key] : $default;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool+    {+        $this->validateKey($key);+        $this->storage[$key] = $value;++        return true;+    }++    /**+     * @throws InvalidCacheKeyException+     */+    public function delete(string $key): bool+    {+        $this->validateKey($key);+        unset($this->storage[$key]);++        return true;+    }++    public function clear(): bool+    {+        $this->storage = [];++        return true;+    }++    /**+     * @param string[] $keys+     *+     * @throws InvalidArgumentException+     *+     * @return iterable<string, mixed>+     */+    public function getMultiple(iterable $keys, mixed $default = null): iterable+    {+        $items = [];+        foreach ($keys as $key) {+            $items[$key] = $this->get($key, $default);+        }++        return $items;+    }++    /**+     * @throws InvalidArgumentException
     * @throws InvalidCacheKeyException
freezemage0

comment created time in 3 days

more