AsFofocavel   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 72
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A infos() 0 4 1
A fatos() 0 4 1
A setDiario() 0 9 1
A diario() 0 5 1
A addDataInfo() 0 9 1
A bootAsFofocavel() 0 9 1
1
<?php
2
3
namespace Telefonica\Traits;
4
5
use Log;
6
7
trait AsFofocavel
8
{
9
    
10
    /**
11
     * One To Many (Polymorphic) - Feature FA
12
     *
13
     * @return void
14
     */
15
16
    public function infos()
17
    {
18
        return $this->morphMany('Population\Models\Market\Abouts\Info', 'infoable');
0 ignored issues
show
Bug introduced by
It seems like morphMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
19
    }
20
21
    public function fatos()
22
    {
23
        return $this->morphMany('Population\Models\Identity\Subjetivos\Fato', 'fatoable');
0 ignored issues
show
Bug introduced by
It seems like morphMany() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
24
    }
25
26
    /**
27
     * Ajudantes que chamam outras funcoes
28
     */
29
    public function setDiario($date, $text)
30
    {
31
        $this->fatos()->create(
32
            [
33
            'date' => $date,
34
            'text' => $text
35
            ]
36
        );
37
    }
38
    /**
39
     * Construtores
40
     */
41
    public function diario($date, $comment)
0 ignored issues
show
Unused Code introduced by
The parameter $date is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $comment is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        // @todo 
44
        return true;
45
    }
46
    
47
48
    /**
49
     * DataInfo do Usuario - @todo Refazer
50
     *
51
     * @param  array $data
52
     * @return void
53
     */
54
    public function addDataInfo($data)
55
    {
56
        // @todo Refazer
57
        return $this->infos()->create(
0 ignored issues
show
Bug introduced by
The method create cannot be called on $this->infos() (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
58
            [
59
            'text' => implode(';', $data)
60
            ]
61
        );
62
    }
63
64
    /**
65
     * Events
66
     */
67
    public static function bootAsFofocavel()                                                                                                                                                             
68
    {
69
70
        // static::deleting(function (self $user) {
71
        //     optional($user->photos)->each(function (Photo $photo) {
72
        //         $photo->delete();
73
        //     });
74
        // });
75
    }
76
    
77
78
}
79