-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Telegram\Message\Entity; | ||
|
||
/** This object represents an animated emoji that displays a random value. */ | ||
readonly class Dice implements DiceInterface | ||
{ | ||
/** | ||
* @param Dice\Emoji $emoji | ||
* @param Dice\Value $value | ||
*/ | ||
public function __construct( | ||
public Dice\Emoji $emoji, | ||
public Dice\Value $value, | ||
) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Telegram\Message\Entity\Dice; | ||
|
||
use Core\Common\Entity\StringValueObject; | ||
|
||
/** Emoji on which the dice throw animation is based */ | ||
class Emoji extends StringValueObject | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Telegram\Message\Entity\Dice; | ||
|
||
use Core\Common\Entity\IntValueObject; | ||
|
||
/** Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji */ | ||
class Value extends IntValueObject | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Telegram\Message\Entity; | ||
|
||
interface DiceInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Telegram\Message\Proxy\Dice; | ||
|
||
use Core\Telegram\Message\Entity\Dice; | ||
use JetBrains\PhpStorm\ArrayShape; | ||
|
||
readonly class AssociativeArray extends Dice | ||
{ | ||
public function __construct( | ||
#[ArrayShape([ | ||
'emoji' => 'string', | ||
'value' => 'int', | ||
])] array $data | ||
) | ||
{ | ||
parent::__construct( | ||
new Dice\Emoji($data['emoji']), | ||
new Dice\Value($data['value']) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Tests\Telegram\Message\Entity; | ||
|
||
use Core\Telegram\Message\Entity\Contact; | ||
use Core\Telegram\Message\Entity\Dice; | ||
use Core\Telegram\User\Entity\User; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DiceTest extends TestCase | ||
{ | ||
public function testGetValues() | ||
{ | ||
$object = new Dice( | ||
new Dice\Emoji('emoji'), | ||
new Dice\Value(10), | ||
); | ||
|
||
$this->assertEquals( | ||
'emoji', | ||
$object->emoji->getValue() | ||
); | ||
|
||
$this->assertEquals( | ||
10, | ||
$object->value->getValue() | ||
); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests-core/Telegram/Message/Proxy/Dice/AssociativeArrayTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Tests\Telegram\Message\Proxy\Dice; | ||
|
||
use Core\Telegram\Message\Proxy\Dice\AssociativeArray; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AssociativeArrayTest extends TestCase | ||
{ | ||
public function testGetValues() | ||
{ | ||
$object = new AssociativeArray([ | ||
'emoji' => 'emoji', | ||
'value' => 10, | ||
]); | ||
|
||
$this->assertEquals( | ||
'emoji', | ||
$object->emoji->getValue() | ||
); | ||
|
||
$this->assertEquals( | ||
10, | ||
$object->value->getValue() | ||
); | ||
} | ||
} |