Honeypot   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A render() 0 4 1
1
<?php
2
namespace Rocket\UI\Forms\Fields;
3
4
/**
5
 * Manage hidden fields
6
 */
7
8
/**
9
 * Hidden field
10
 *
11
 * @author Stéphane Goetz
12
 */
13
class Honeypot extends Field
14
{
15
    /**
16
     * Extends the type
17
     * @param string $id
18
     * @param array $data
19
     */
20
    public function __construct($id, $data = [])
21
    {
22
        $this->id = $data;
0 ignored issues
show
Documentation Bug introduced by
It seems like $data of type array is incompatible with the declared type string of property $id.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
        $this->time_field = $data['time'];
0 ignored issues
show
Bug introduced by
The property time_field does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
    }
25
26
    /**
27
     * Override the attributes to stay hidden
28
     */
29
    public function render()
30
    {
31
        return (new \Msurguy\Honeypot\Honeypot())->getFormHTML($this->id, $this->time_field);
32
    }
33
}
34