Skip to content

Commit

Permalink
CHG: Refactoring the namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
rvelhote committed Oct 17, 2016
1 parent 699c711 commit cc0ddaf
Show file tree
Hide file tree
Showing 29 changed files with 110 additions and 110 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ if($validationResult->isValid()) {
// A game result can be either a Win or a Tie. A Win contains the players that participated (and their plays) as well
// as the winning rule. A Tie just contains the players. You can do whatever you want with the data.
if($result instanceof Tie) {
/** @var Balwan\RockPaperScissor\Game\Result\Tie $result */
/** @var Welhott\RockPaperScissor\Game\Result\Tie $result */
print "\n» ".$result->getPlayer1()->getName()." tied ".$result->getPlayer2()->getName()."\n";
print "» ".$result->getPlayer1()->getName(). " played ".$result->getPlayer1()->getPlay()."\n";
print "» ".$result->getPlayer2()->getName(). " played ".$result->getPlayer2()->getPlay()."\n";
} else if($result instanceof Win) {
/** @var Balwan\RockPaperScissor\Game\Result\Win $result */
/** @var Welhott\RockPaperScissor\Game\Result\Win $result */
print "\n» ".$result->getRule()->getText()."\n================\n";

// Detailed
Expand All @@ -81,10 +81,10 @@ if($validationResult->isValid()) {
echo "Oops :P";
}
} else {
$reflection = new ReflectionClass("\\Balwan\\RockPaperScissor\\Validation\\ValidationMessage");
$reflection = new ReflectionClass("\\Welhott\\RockPaperScissor\\Validation\\ValidationMessage");
$constants = $reflection->getConstants();

/** @var \Balwan\RockPaperScissor\Validation\ValidationMessage $message */
/** @var \Welhott\RockPaperScissor\Validation\ValidationMessage $message */
foreach($validationResult->getMessages() as $message) {
$constant = array_search($message->getType(), $constants);
print "» ".$constant." » ".$message->getMessage()."\n";
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "balwan/rock-paper-scissor",
"name": "welhott/rock-paper-scissor",
"type": "library",
"description": "A PHP library to create games based on Rock Paper Scissor.",
"minimum-stability": "stable",
Expand All @@ -13,12 +13,12 @@
],
"autoload": {
"psr-4": {
"Balwan\\RockPaperScissor\\": "src/"
"Welhott\\RockPaperScissor\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Balwan\\RockPaperScissor\\": "tests/"
"Welhott\\RockPaperScissor\\": "tests/"
}
},
"require": {
Expand Down
20 changes: 10 additions & 10 deletions examples/sample-rockpaperscissor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use Balwan\RockPaperScissor\Game\Game;
use Balwan\RockPaperScissor\Game\Result\Tie;
use Balwan\RockPaperScissor\Game\Result\Win;
use Balwan\RockPaperScissor\Move\Move;
use Balwan\RockPaperScissor\Rule\RuleCollection;
use Balwan\RockPaperScissor\Rule\Rule;
use Welhott\RockPaperScissor\Game\Game;
use Welhott\RockPaperScissor\Game\Result\Tie;
use Welhott\RockPaperScissor\Game\Result\Win;
use Welhott\RockPaperScissor\Move\Move;
use Welhott\RockPaperScissor\Rule\RuleCollection;
use Welhott\RockPaperScissor\Rule\Rule;

require "../vendor/autoload.php";

Expand All @@ -52,11 +52,11 @@
// A game result can be either a Win or a Tie. A Win contains the players that participated (and their plays) as well
// as the winning rule. A Tie just contains the players. You can do whatever you want with the data.
if($result instanceof Tie) {
/** @var Balwan\RockPaperScissor\Game\Result\Tie $result */
/** @var Welhott\RockPaperScissor\Game\Result\Tie $result */
print "\n» ".$result->getPlayer1()->getPlay()." vs ".$result->getPlayer2()->getPlay()."\n";
print "» TIE\n";
} else if($result instanceof Win) {
/** @var Balwan\RockPaperScissor\Game\Result\Win $result */
/** @var Welhott\RockPaperScissor\Game\Result\Win $result */
print "\n» ".$result->getRule()->getText()."\n================\n";

// Detailed
Expand All @@ -67,10 +67,10 @@
echo "Oops :P";
}
} else {
$reflection = new ReflectionClass("\\Balwan\\RockPaperScissor\\Validation\\ValidationMessage");
$reflection = new ReflectionClass("\\Welhott\\RockPaperScissor\\Validation\\ValidationMessage");
$constants = $reflection->getConstants();

/** @var \Balwan\RockPaperScissor\Validation\ValidationMessage $message */
/** @var \Welhott\RockPaperScissor\Validation\ValidationMessage $message */
foreach($validationResult->getMessages() as $message) {
$constant = array_search($message->getType(), $constants);
print "» ".$constant." » ".$message->getMessage()."\n";
Expand Down
6 changes: 3 additions & 3 deletions src/DataProvider/DataProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\DataProvider;
namespace Welhott\RockPaperScissor\DataProvider;

use Balwan\RockPaperScissor\Move\MoveCollection;
use Welhott\RockPaperScissor\Move\MoveCollection;

/**
* Interface DataProviderInterface
* @package Balwan\RockPaperScissor\DataProvider
* @package Welhott\RockPaperScissor\DataProvider
*/
interface DataProviderInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidRuleException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Exception;
namespace Welhott\RockPaperScissor\Exception;

use Exception;

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/MissingDataException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Exception;
namespace Welhott\RockPaperScissor\Exception;

use Exception;

Expand Down
14 changes: 7 additions & 7 deletions src/Game/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Game;
namespace Welhott\RockPaperScissor\Game;

use Balwan\RockPaperScissor\Game\Result\AbstractGameResult;
use Balwan\RockPaperScissor\Game\Result\Win;
use Balwan\RockPaperScissor\Game\Result\Tie;
use Balwan\RockPaperScissor\Move\Move;
use Balwan\RockPaperScissor\Rule\RuleCollection;
use Welhott\RockPaperScissor\Game\Result\AbstractGameResult;
use Welhott\RockPaperScissor\Game\Result\Win;
use Welhott\RockPaperScissor\Game\Result\Tie;
use Welhott\RockPaperScissor\Move\Move;
use Welhott\RockPaperScissor\Rule\RuleCollection;

/**
* This class defines a game between two players and the set of rules that is to be applied.
* @package Balwan\RockPaperScissor\Game
* @package Welhott\RockPaperScissor\Game
*/
class Game
{
Expand Down
6 changes: 3 additions & 3 deletions src/Game/Result/AbstractGameResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Game\Result;
namespace Welhott\RockPaperScissor\Game\Result;

use Balwan\RockPaperScissor\Move\Move;
use Welhott\RockPaperScissor\Move\Move;

/**
* Abstract Class AbstractGameResult
* @package Balwan\RockPaperScissor\Game\Result
* @package Welhott\RockPaperScissor\Game\Result
*/
abstract class AbstractGameResult
{
Expand Down
6 changes: 3 additions & 3 deletions src/Game/Result/Tie.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Game\Result;
namespace Welhott\RockPaperScissor\Game\Result;

use Balwan\RockPaperScissor\Move\Move;
use Welhott\RockPaperScissor\Move\Move;

/**
* Class Tie
* @package Balwan\RockPaperScissor\Game\Result
* @package Welhott\RockPaperScissor\Game\Result
*/
class Tie extends AbstractGameResult
{
Expand Down
8 changes: 4 additions & 4 deletions src/Game/Result/Win.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Game\Result;
namespace Welhott\RockPaperScissor\Game\Result;

use Balwan\RockPaperScissor\Move\Move;
use Balwan\RockPaperScissor\Rule\Rule;
use Welhott\RockPaperScissor\Move\Move;
use Welhott\RockPaperScissor\Rule\Rule;

/**
* Class Win
* @package Balwan\RockPaperScissor\Game\Result
* @package Welhott\RockPaperScissor\Game\Result
*/
class Win extends AbstractGameResult
{
Expand Down
6 changes: 3 additions & 3 deletions src/Move/Move.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Move;
namespace Welhott\RockPaperScissor\Move;

use Balwan\RockPaperScissor\Exception\MissingDataException;
use Welhott\RockPaperScissor\Exception\MissingDataException;

/**
* This class represents a single player that is participating in a game.
* @package Balwan\RockPaperScissor\Move
* @package Welhott\RockPaperScissor\Move
*/
class Move {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/Move/MoveCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Move;
namespace Welhott\RockPaperScissor\Move;

use Countable;
use ArrayIterator;
use IteratorAggregate;

/**
* Class PlayerCollection
* @package Balwan\RockPaperScissor\Move
* @package Welhott\RockPaperScissor\Move
*/
class MoveCollection implements IteratorAggregate, Countable
{
Expand Down
6 changes: 3 additions & 3 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Rule;
namespace Welhott\RockPaperScissor\Rule;

use Balwan\RockPaperScissor\Exception\InvalidRuleException;
use Balwan\RockPaperScissor\Exception\MissingDataException;
use Welhott\RockPaperScissor\Exception\InvalidRuleException;
use Welhott\RockPaperScissor\Exception\MissingDataException;

/**
* Class Rule
Expand Down
20 changes: 10 additions & 10 deletions src/Rule/RuleCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Rule;
namespace Welhott\RockPaperScissor\Rule;

use ArrayIterator;
use IteratorAggregate;
use Balwan\RockPaperScissor\Validation\ValidationMessage;
use Balwan\RockPaperScissor\Validation\ValidationResult;
use Balwan\RockPaperScissor\Validation\ValidationRuleInterface;
use Balwan\RockPaperScissor\Validation\Rule\RuleBalancedWeaponOutcome;
use Balwan\RockPaperScissor\Validation\Rule\RuleTotalWeaponsIsOddNumber;
use Balwan\RockPaperScissor\Validation\Rule\RuleExpectedTotalRules;
use Welhott\RockPaperScissor\Validation\ValidationMessage;
use Welhott\RockPaperScissor\Validation\ValidationResult;
use Welhott\RockPaperScissor\Validation\ValidationRuleInterface;
use Welhott\RockPaperScissor\Validation\Rule\RuleBalancedWeaponOutcome;
use Welhott\RockPaperScissor\Validation\Rule\RuleTotalWeaponsIsOddNumber;
use Welhott\RockPaperScissor\Validation\Rule\RuleExpectedTotalRules;

/**
* Class RuleCollection
* @package Balwan\RockPaperScissor\Rule
* @package Welhott\RockPaperScissor\Rule
*/
class RuleCollection implements IteratorAggregate
{
Expand Down Expand Up @@ -69,9 +69,9 @@ public function add(Rule $rule)
* @param string $winner The weapon that wins this rule.
* @param string $loser The weapon that loses this rule.
*
* @return Rule|null An instance of Balwan\RockPaperScissor\Rule\Rule or null if the rule is not found
* @return Rule|null An instance of Welhott\RockPaperScissor\Rule\Rule or null if the rule is not found
*
* @see Balwan\RockPaperScissor\Rules\Rule
* @see Welhott\RockPaperScissor\Rules\Rule
*
* TODO Implement Null Object Pattern?
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Validation/Rule/RuleBalancedWeaponOutcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Validation\Rule;
namespace Welhott\RockPaperScissor\Validation\Rule;

use Balwan\RockPaperScissor\Rule\Rule;
use Balwan\RockPaperScissor\Rule\RuleCollection;
use Balwan\RockPaperScissor\Validation\ValidationMessage;
use Balwan\RockPaperScissor\Validation\ValidationRuleInterface;
use Welhott\RockPaperScissor\Rule\Rule;
use Welhott\RockPaperScissor\Rule\RuleCollection;
use Welhott\RockPaperScissor\Validation\ValidationMessage;
use Welhott\RockPaperScissor\Validation\ValidationRuleInterface;

/**
* Class RuleBalancedWeaponOutcome
* @package Balwan\RockPaperScissor\Rule\Validation
* @package Welhott\RockPaperScissor\Rule\Validation
*/
class RuleBalancedWeaponOutcome implements ValidationRuleInterface
{
Expand Down
8 changes: 4 additions & 4 deletions src/Validation/Rule/RuleExpectedTotalRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Validation\Rule;
namespace Welhott\RockPaperScissor\Validation\Rule;

use Balwan\RockPaperScissor\Validation\ValidationMessage;
use Balwan\RockPaperScissor\Validation\ValidationRuleInterface;
use Welhott\RockPaperScissor\Validation\ValidationMessage;
use Welhott\RockPaperScissor\Validation\ValidationRuleInterface;

/**
* Class RuleExpectedTotalRules
* @package Balwan\RockPaperScissor\Rule\Validation\Rule
* @package Welhott\RockPaperScissor\Rule\Validation\Rule
*/
class RuleExpectedTotalRules implements ValidationRuleInterface
{
Expand Down
8 changes: 4 additions & 4 deletions src/Validation/Rule/RuleTotalWeaponsIsOddNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Validation\Rule;
namespace Welhott\RockPaperScissor\Validation\Rule;

use Balwan\RockPaperScissor\Validation\ValidationMessage;
use Balwan\RockPaperScissor\Validation\ValidationRuleInterface;
use Welhott\RockPaperScissor\Validation\ValidationMessage;
use Welhott\RockPaperScissor\Validation\ValidationRuleInterface;

/**
* Class RuleTotalWeaponsIsOddNumber
* @package Balwan\RockPaperScissor\Rule\Validation
* @package Welhott\RockPaperScissor\Rule\Validation
*/
class RuleTotalWeaponsIsOddNumber implements ValidationRuleInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/ValidationMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Validation;
namespace Welhott\RockPaperScissor\Validation;

/**
* Class Message
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ValidationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Validation;
namespace Welhott\RockPaperScissor\Validation;

/**
* Class ValidationResult
* @package Balwan\RockPaperScissor\Rule\Validation
* @package Welhott\RockPaperScissor\Rule\Validation
*/
class ValidationResult
{
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ValidationRuleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Balwan\RockPaperScissor\Validation;
namespace Welhott\RockPaperScissor\Validation;

/**
* Interface ValidationRule
* @package Balwan\RockPaperScissor\Rule\Validation
* @package Welhott\RockPaperScissor\Rule\Validation
*/
interface ValidationRuleInterface
{
Expand Down
Loading

0 comments on commit cc0ddaf

Please sign in to comment.