Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..

Decoded Output download

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Notifier\Bridge\Discord\Tests\Embeds;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordEmbed;
use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordFieldEmbedObject;
use Symfony\Component\Notifier\Exception\LengthException;

final class DiscordEmbedTest extends TestCase
{
    public function testCanBeInstantiated()
    {
        $embed = (new DiscordEmbed())
            ->title('foo')
            ->description('bar')
            ->addField((new DiscordFieldEmbedObject())
                ->name('baz')
                ->value('qux')
            );

        $this->assertSame([
            'title' => 'foo',
            'description' => 'bar',
            'fields' => [
                [
                    'name' => 'baz',
                    'value' => 'qux',
                ],
            ],
        ], $embed->toArray());
    }

    public function testThrowsWhenTitleExceedsCharacterLimit()
    {
        $this->expectException(LengthException::class);
        $this->expectExceptionMessage('Maximum length for the title is 256 characters.');

        (new DiscordEmbed())->title(str_repeat('h', 257));
    }

    public function testThrowsWhenDescriptionExceedsCharacterLimit()
    {
        $this->expectException(LengthException::class);
        $this->expectExceptionMessage('Maximum length for the description is 4096 characters.');

        (new DiscordEmbed())->description(str_repeat('h', 4097));
    }

    public function testThrowsWhenFieldsLimitReached()
    {
        $embed = new DiscordEmbed();
        for ($i = 0; $i < 25; ++$i) {
            $embed->addField((new DiscordFieldEmbedObject())
                ->name('baz')
                ->value('qux')
            );
        }

        $this->expectException(\LogicException::class);
        $this->expectExceptionMessage('Maximum number of fields should not exceed 25.');

        $embed->addField((new DiscordFieldEmbedObject())
            ->name('fail')
            ->value('fail')
        );
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Notifier\Bridge\Discord\Tests\Embeds;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordEmbed;
use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordFieldEmbedObject;
use Symfony\Component\Notifier\Exception\LengthException;

final class DiscordEmbedTest extends TestCase
{
    public function testCanBeInstantiated()
    {
        $embed = (new DiscordEmbed())
            ->title('foo')
            ->description('bar')
            ->addField((new DiscordFieldEmbedObject())
                ->name('baz')
                ->value('qux')
            );

        $this->assertSame([
            'title' => 'foo',
            'description' => 'bar',
            'fields' => [
                [
                    'name' => 'baz',
                    'value' => 'qux',
                ],
            ],
        ], $embed->toArray());
    }

    public function testThrowsWhenTitleExceedsCharacterLimit()
    {
        $this->expectException(LengthException::class);
        $this->expectExceptionMessage('Maximum length for the title is 256 characters.');

        (new DiscordEmbed())->title(str_repeat('h', 257));
    }

    public function testThrowsWhenDescriptionExceedsCharacterLimit()
    {
        $this->expectException(LengthException::class);
        $this->expectExceptionMessage('Maximum length for the description is 4096 characters.');

        (new DiscordEmbed())->description(str_repeat('h', 4097));
    }

    public function testThrowsWhenFieldsLimitReached()
    {
        $embed = new DiscordEmbed();
        for ($i = 0; $i < 25; ++$i) {
            $embed->addField((new DiscordFieldEmbedObject())
                ->name('baz')
                ->value('qux')
            );
        }

        $this->expectException(\LogicException::class);
        $this->expectExceptionMessage('Maximum number of fields should not exceed 25.');

        $embed->addField((new DiscordFieldEmbedObject())
            ->name('fail')
            ->value('fail')
        );
    }
}

Function Calls

None

Variables

None

Stats

MD5 db6d309b897d6f5c26346e724c8ee73e
Eval Count 0
Decode Time 123 ms