Skip to content

Commit

Permalink
Update minimum number of players from 4 to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilleGF committed Nov 4, 2017
1 parent 8edde94 commit 0c443af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![License](https://poser.pugx.org/guillegf/secret-santa/license)](https://packagist.org/packages/guillegf/secret-santa)

* Repository: https://github.com/GuilleGF/SecretSantaPHP
* Version: 1.2.0
* Version: 1.3.0
* License: MIT, see [LICENSE](LICENSE)

## Description
Expand All @@ -31,13 +31,13 @@ documentation.
To add this dependency using the command, run the following from within your
project directory:
```
composer require guillegf/secret-santa "~1.2"
composer require guillegf/secret-santa "~1.3"
```

Alternatively, add the dependency directly to your `composer.json` file:
```json
"require": {
"guillegf/secret-santa": "~1.2"
"guillegf/secret-santa": "~1.3"
}
```
## Usage
Expand Down
4 changes: 2 additions & 2 deletions src/SecretSanta.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public function play()
*/
private function combinePlayers()
{
if (count($this->players) < 4) {
throw new SecretSantaException("Not enough players to play, at least 4 players are required");
if (count($this->players) < 3) {
throw new SecretSantaException("Not enough players to play, at least 3 players are required");
}

$retry = count($this->players) + $this->players->countExclusivePlayers();
Expand Down
12 changes: 12 additions & 0 deletions tests/SecretSantaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ public function testSameTwoCouples()
$secretSanta->addCouple('Player', '[email protected]', 'Couple', '[email protected]');
}

public function testThreePlayers()
{
$secretSanta = new SecretSanta();
$secretSanta->addPlayer('Player', '[email protected]');
$secretSanta->addPlayer('Player2', '[email protected]');
$secretSanta->addPlayer('Player3', '[email protected]');

$combination = $secretSanta->play();

$this->assertSame(3 , count($combination));
}

public function testTwoCouples()
{
$secretSanta = new SecretSanta();
Expand Down

0 comments on commit 0c443af

Please sign in to comment.