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.

NumberOfDocumentsWithStatus::name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\UploadFile\CompletionConditions;
4
5
use BristolSU\Module\UploadFile\Models\File;
6
use BristolSU\Support\ActivityInstance\ActivityInstance;
7
use BristolSU\Support\Completion\Contracts\CompletionCondition;
8
use BristolSU\Support\ModuleInstance\Contracts\ModuleInstance;
9
use FormSchema\Schema\Form;
10
11
class NumberOfDocumentsWithStatus extends CompletionCondition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class NumberOfDocumentsWithStatus
Loading history...
12
{
13
14 4
    public function isComplete($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isComplete()
Loading history...
15
    {
16
        return File::forResource($activityInstance->id, $moduleInstance->id())->get()->filter(function(File $file) use ($settings) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
17 4
            return $file->status === $settings['status'];
18 4
        })->count() >= $settings['number_of_files'];
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
19
    }
20
21 4
    public function percentage($settings, ActivityInstance $activityInstance, ModuleInstance $moduleInstance): int
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function percentage()
Loading history...
22
    {
23
        $count = File::forResource($activityInstance->id, $moduleInstance->id())->get()->filter(function(File $file) use ($settings) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
24 3
            return $file->status === $settings['status'];
25 4
        })->count();
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
26 4
        $needed = ( $settings['number_of_files'] ?? 1);
27
28 4
        $percentage = (int) round(($count/$needed) * 100, 0);
29
30 4
        if($percentage > 100) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
31 1
            return 100; 
32
        }
33 3
        return $percentage;
34
    }
35
36
37 1
    public function options(): Form
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function options()
Loading history...
38
    {
39 1
        return \FormSchema\Generator\Form::make()->withField(
40 1
            \FormSchema\Generator\Field::input('number_of_files')->inputType('number')->label('Number of Files')
41 1
                ->required(true)->default(1)->hint('The number of files that must be submitted')
42 1
                ->help('The number of documents that need to be submitted for the module to be marked as complete.')
43 1
        )->withField(
44 1
            \FormSchema\Generator\Field::input('status')->inputType('text')->label('Status')
45 1
                ->required(true)->default('Awaiting Approval')->hint('The status the files must be')
46 1
                ->help('The status of the files. The module will be complete when the number of files submitted have this status.')
47 1
        )->getSchema();
48
    }
49
50 1
    public function name(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function name()
Loading history...
51
    {
52 1
        return 'A number of documents with a given status have been submitted';
53
    }
54
55 1
    public function description(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function description()
Loading history...
56
    {
57 1
        return 'Complete when a given number of documents have been submitted and given a specific status';
58
    }
59
60 1
    public function alias(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function alias()
Loading history...
61
    {
62 1
        return 'number_of_files_submitted_with_status';
63
    }
64
    
65
}