Completed
Push — master ( 6f92e6...cbba0d )
by Fèvre
9s
created

PollsAnswer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A _getPercentage() 0 4 1
1
<?php
2
namespace App\Model\Entity;
3
4
use Cake\ORM\Entity;
5
6
/**
7
 * PollsAnswer Entity
8
 *
9
 * @property int $id
10
 * @property int $poll_id
11
 * @property string $response
12
 * @property int $user_count
13
 * @property \Cake\I18n\Time $created
14
 * @property \Cake\I18n\Time $modified
15
 *
16
 * @property \App\Model\Entity\Poll $poll
17
 */
18
class PollsAnswer extends Entity
19
{
20
21
    /**
22
     * Fields that can be mass assigned using newEntity() or patchEntity().
23
     *
24
     * @var array
25
     */
26
    protected $_accessible = [
27
        '*' => true,
28
        'id' => false
29
    ];
30
31
    /**
32
     * Get the percentage of the answer's vote relative to the total of vote.
33
     *
34
     * @return int
35
     */
36
    protected function _getPercentage()
37
    {
38
        return ($this->user_count * 100) / $this->poll->user_count;
39
    }
40
}
41