GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CodeCount   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTotalPoints() 0 3 1
A setRank() 0 8 2
A getCodeCount() 0 5 1
A setCodeCount() 0 5 1
1
<?php
2
    /**
3
     * Created by PhpStorm.
4
     * User: caspa
5
     * Date: 31.05.2018
6
     * Time: 11:39.
7
     */
8
9
namespace App\Http\Controllers;
10
11
use Illuminate\Support\Facades\DB;
12
13
    class CodeCount extends Controller
14
    {
15
        /**
16
         * Anzahl codes in DB hinterlegen.
17
         *
18
         * @param $codeCount
19
         *
20
         * @return int
21
         */
22
        public static function setCodeCount($codeCount)
23
        {
24
            DB::table('game_admin')->insert(['code_count' => $codeCount, 'total_points' => $codeCount]);
25
26
            return intval($codeCount);
27
        }
28
29
        /**
30
         * Anzahl codes aus DB holen und ausgeben.
31
         *
32
         * @return mixed
33
         */
34
        public function getCodeCount()
35
        {
36
            $codeCount = DB::table('game_admin')->select('code_count')->first()->code_count;
37
38
            return $codeCount;
39
        }
40
41
        /**
42
         * Anzahl codes aus DB holen und ausgeben.
43
         *
44
         * @return mixed
45
         */
46
        public static function getTotalPoints()
47
        {
48
            return $totalPoints = DB::table('game_admin')->select('total_points')->first();
0 ignored issues
show
Unused Code introduced by
The assignment to $totalPoints is dead and can be removed.
Loading history...
49
        }
50
51
        public static function setRank()
52
        {
53
            $totalPoints = self::getTotalPoints();
54
            $rankObj = DB::select("SELECT * FROM users WHERE total_points = $totalPoints ORDER BY TIMEDIFF(start, end) DESC;");
55
56
            for ($i = 0; $i < count($rankObj); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
57
                DB::table('users')->where('name_gen', $rankObj[$i]->name_gen)->update(['rank' => (++$i)]);
58
                $i--;
59
            }
60
        }
61
    }
62