Completed
Branch master (a6481d)
by Fèvre
02:12
created

UserEntity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAvatarSmallAttribute() 0 4 1
A getAvatarMediumAttribute() 0 4 1
A getAvatarBigAttribute() 0 4 1
A getProfileBackgroundAttribute() 0 4 1
1
<?php
2
namespace Xetaravel\Models\Entities;
3
4
use Xetaravel\Utility\UserUtility;
5
6
trait UserEntity
7
{
8
    /**
9
     * Get the small avatar.
10
     *
11
     * @return string
12
     */
13
    public function getAvatarSmallAttribute(): string
14
    {
15
        return $this->getMedia('avatar')[0]->getUrl('thumbnail.small');
0 ignored issues
show
Bug introduced by
It seems like getMedia() 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...
16
    }
17
18
    /**
19
     * Get the medium avatar.
20
     *
21
     * @return string
22
     */
23
    public function getAvatarMediumAttribute(): string
24
    {
25
        return $this->getMedia('avatar')[0]->getUrl('thumbnail.medium');
0 ignored issues
show
Bug introduced by
It seems like getMedia() 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...
26
    }
27
28
    /**
29
     * Get the big avatar.
30
     *
31
     * @return string
32
     */
33
    public function getAvatarBigAttribute(): string
34
    {
35
        return $this->getMedia('avatar')[0]->getUrl('thumbnail.big');
0 ignored issues
show
Bug introduced by
It seems like getMedia() 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...
36
    }
37
38
    /**
39
     * Get the porofile background.
40
     *
41
     * @return string
42
     */
43
    public function getProfileBackgroundAttribute(): string
44
    {
45
        return UserUtility::getProfileBackground();
46
    }
47
}
48