Passed
Push — master ( 31921a...9884a8 )
by Johan
05:54
created

PokerSquares::game()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 9.1992

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 5
cts 16
cp 0.3125
rs 9.568
c 0
b 0
f 0
cc 4
nc 8
nop 0
crap 9.1992
1
<?php
2
3
/*
4
* Card class
5
*/
6
7
declare(strict_types=1);
8
9
// Folder \Controllers containing classes
10
namespace Joki20\Http\Controllers;
11
12
// use Joki20\Http\Controllers\PokerSquares;
13
use Joki20\Http\Controllers\Scoring;
14
use Joki20\Http\Controllers\Setup;
15
16
/**
17
 * Class PokerSquares.
18
 */
19
20
class PokerSquares
21
{
22
    use Setup;
23
    use Scoring;
24
25 1
    public function game() // new game
26
    {
27
        // SET NAME
28 1
        empty($_POST) ? print_r($this->name()) : null;
29
        // SET NAME RESULT
30 1
        if (isset($_POST['setName'])) {
31
            $this->prepareSessions(); // save name and reset points
32
            $this->shuffleDeck(); // shuffle deck, store in session('deck');
33
            $this->prepareStack(); // create draw stack
34
            print_r($this->displayGrid()); // setup grid
35
        }
36
        // // IF CARD WAS PLACED ($_POST begins with 'place')
37 1
        if (isset($_POST['placeCard'])) {
38
            $this->placeCard();
39
            $this->prepareStack();
40
            $this->setPointsSessions();
41
            $this->checkFullRow();
42
            $this->checkFullColumn();
43
            print_r($this->displayGrid());
44
            $this->storeToDatabase();
45
        }
46 1
    }
47
}
48