Skip to content

Commit 6c3826c

Browse files
author
Aner
committed
fix indents
1 parent 7f96bb7 commit 6c3826c

File tree

2 files changed

+171
-171
lines changed

2 files changed

+171
-171
lines changed

src/Card.php

Lines changed: 143 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -10,149 +10,149 @@
1010
*/
1111
class Card{
1212

13-
const ACE = 100;
14-
const JACK = 101;
15-
const QUEEN = 102;
16-
const KING = 103;
17-
18-
/**
19-
* The suit of this card
20-
* @var Suit
21-
*/
22-
protected $suit;
23-
24-
/**
25-
* Face value
26-
* @var int
27-
*/
28-
protected $faceValue;
29-
30-
/**
31-
* A new playing card
32-
* @param int $faceValue the face value of the card.
33-
* @param Suit $suit the suit of the card.
34-
*
35-
* @throws \InvalidArgumentException
36-
*/
37-
public function __construct($faceValue, Suit $suit){
38-
39-
if($this->isValidFaceValue($faceValue)){
40-
41-
$this->faceValue = $faceValue;
42-
$this->suit= $suit;
43-
44-
}else{
45-
throw new \InvalidArgumentException("The face value in not valide: $faceValue");
13+
const ACE = 100;
14+
const JACK = 101;
15+
const QUEEN = 102;
16+
const KING = 103;
17+
18+
/**
19+
* The suit of this card
20+
* @var Suit
21+
*/
22+
protected $suit;
23+
24+
/**
25+
* Face value
26+
* @var int
27+
*/
28+
protected $faceValue;
29+
30+
/**
31+
* A new playing card
32+
* @param int $faceValue the face value of the card.
33+
* @param Suit $suit the suit of the card.
34+
*
35+
* @throws \InvalidArgumentException
36+
*/
37+
public function __construct($faceValue, Suit $suit){
38+
39+
if($this->isValidFaceValue($faceValue)){
40+
41+
$this->faceValue = $faceValue;
42+
$this->suit= $suit;
43+
44+
}else{
45+
throw new \InvalidArgumentException("The face value in not valide: $faceValue");
46+
}
47+
}
48+
49+
50+
protected function isValidFaceValue($value){
51+
52+
if($value >= 2 && $value <= 10){
53+
return true;
54+
}
55+
56+
if($this->isFaceCardOrAce($value)){
57+
return true;
58+
}
59+
60+
return false;
61+
}
62+
63+
protected function isFaceCardOrAce($value){
64+
65+
return (
66+
$value == static::ACE
67+
||
68+
$value == static::JACK
69+
||
70+
$value == static::QUEEN
71+
||
72+
$value == static::KING);
73+
74+
}
75+
76+
/**
77+
* Get the Face value of the card
78+
*
79+
* @return int face value
80+
*/
81+
public function value(){
82+
83+
return $this->faceValue;
84+
}
85+
86+
/**
87+
* Get the Suit of the card
88+
*
89+
* @return Suit
90+
*/
91+
public function suit(){
92+
93+
return $this->suit;
94+
}
95+
96+
/**
97+
* Get the suit name the card
98+
*
99+
* @return string
100+
*/
101+
public function suitName(){
102+
103+
return $this->suit->name();
104+
}
105+
106+
/*
107+
* Is this an Ace
108+
*
109+
* @return bool
110+
*/
111+
public function isAce(){
112+
113+
return $this->faceValue == static::ACE;
114+
}
115+
116+
/**
117+
* Is this a King
118+
*
119+
* @return bool
120+
*/
121+
public function isKing(){
122+
123+
return $this->faceValue == static::KING;
124+
}
125+
126+
/**
127+
* Is this a Queen
128+
*
129+
* @return bool
130+
*/
131+
public function isQueen(){
132+
133+
return $this->faceValue == static::QUEEN;
134+
}
135+
136+
/**
137+
* Is this a Jack
138+
*
139+
* @return bool
140+
*/
141+
public function isJack(){
142+
143+
return $this->faceValue == static::JACK;
144+
}
145+
146+
/**
147+
* Is Face card. True if the card is King,Queen or Jack
148+
*
149+
* @return bool
150+
*/
151+
public function isFaceCard(){
152+
153+
$face = $this->isKing() || $this->isQueen() || $this->isJack();
154+
155+
return $face;
46156
}
47-
}
48-
49-
50-
protected function isValidFaceValue($value){
51-
52-
if($value >= 2 && $value <= 10){
53-
return true;
54-
}
55-
56-
if($this->isFaceCardOrAce($value)){
57-
return true;
58-
}
59-
60-
return false;
61-
}
62-
63-
protected function isFaceCardOrAce($value){
64-
65-
return (
66-
$value == static::ACE
67-
||
68-
$value == static::JACK
69-
||
70-
$value == static::QUEEN
71-
||
72-
$value == static::KING);
73-
74-
}
75-
76-
/**
77-
* Get the Face value of the card
78-
*
79-
* @return int face value
80-
*/
81-
public function value(){
82-
83-
return $this->faceValue;
84-
}
85-
86-
/**
87-
* Get the Suit of the card
88-
*
89-
* @return Suit
90-
*/
91-
public function suit(){
92-
93-
return $this->suit;
94-
}
95-
96-
/**
97-
* Get the suit name the card
98-
*
99-
* @return string
100-
*/
101-
public function suitName(){
102-
103-
return $this->suit->name();
104-
}
105-
106-
/*
107-
* Is this an Ace
108-
*
109-
* @return bool
110-
*/
111-
public function isAce(){
112-
113-
return $this->faceValue == static::ACE;
114-
}
115-
116-
/**
117-
* Is Face card. True if the card is King,Queen or Jack
118-
*
119-
* @return bool
120-
*/
121-
public function isFaceCard(){
122-
123-
$face = $this->isKing() || $this->isQueen() || $this->isJack();
124-
125-
return $face;
126-
}
127-
128-
/**
129-
* Is this a King
130-
*
131-
* @return bool
132-
*/
133-
public function isKing(){
134-
135-
return $this->faceValue == static::KING;
136-
}
137-
138-
/**
139-
* Is this a Queen
140-
*
141-
* @return bool
142-
*/
143-
public function isQueen(){
144-
145-
return $this->faceValue == static::QUEEN;
146-
}
147-
148-
/**
149-
* Is this a Jack
150-
*
151-
* @return bool
152-
*/
153-
public function isJack(){
154-
155-
return $this->faceValue == static::JACK;
156-
}
157157
}
158158

0 commit comments

Comments
 (0)