Passed
Push — master ( 74ddc4...4602de )
by Mohammad
03:46
created

Forms::getFormStub()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: shanmaseen
5
 * Date: 09/04/19
6
 * Time: 12:02 م
7
 */
8
namespace Shamaseen\Repository\Generator\Forms;
9
10
use Doctrine\DBAL\Schema\Column;
11
12
abstract class Forms
13
{
14
    /**
15
     * @var Column
16
     */
17
    protected $column;
18
19
    public $type = 'text';
20
21
    /**
22
     * Forms constructor.
23
     * @param Column $column
24
     */
25
    public function __construct($column)
26
    {
27
        $this->column = $column;
28
    }
29
30
    abstract function template();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
31
32
    function getType()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
    {
34
35
        switch ($this->column->getName())
36
        {
37
            case "email":
38
                return 'email';
39
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
40
            case "password":
41
                return "password";
42
                break;
43
        }
44
45
        switch ($this->column->getType())
46
        {
47
            case "integer":
48
            case "int":
49
            case "mediumint":
50
            case "bigint":
51
            case "decimal":
52
            case "float":
53
            case "double":
54
                return 'number';
55
                break;
56
57
            case "time":
58
                return 'time';
59
                break;
60
61
            case "date":
62
            case "datetime":
63
            case "timestamp":
64
            case "year":
65
                return 'date';
66
                break;
67
68
            case "boolean":
69
            case "bool":
70
            case "varchat":
71
            case "enum":
72
            case "text":
73
            default:
74
                return 'text';
75
                break;
76
        }
77
    }
78
79
    function getFormStub($type)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
80
    {
81
        return file_get_contents(\Config::get('repository.stubs_path') . "/fields-".$type.".stub");
82
    }
83
}