Completed
Push — master ( 3cca65...6ffe9e )
by Gabriel
05:45
created

RecordsTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A reduceOldEmailsData() 0 16 1
1
<?php
2
3
namespace Nip\MailModule\Models\EmailsTable\Traits\Cleanup;
4
5
use Nip\Database\Query\Update;
6
7
/**
8
 * Trait RecordsTrait
9
 * @package Nip\Mail\Models\Cleanup
10
 */
11
trait RecordsTrait
12
{
13
    protected $sentDateField = 'date_sent';
14
    protected $daysToKeepData = 365;
15
16
    /**
17
     * @return \Nip\Database\Result
18
     */
19 1
    public function reduceOldEmailsData()
20
    {
21
        /** @var Update $query */
22 1
        $query = $this->newUpdateQuery();
0 ignored issues
show
Bug introduced by
It seems like newUpdateQuery() 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...
23 1
        $query->where(
24 1
            '`' . $this->sentDateField . '` <= DATE_SUB(CURRENT_DATE(), INTERVAL ' . $this->daysToKeepData . ' DAY)'
25
        );
26 1
        $query->data([
0 ignored issues
show
Unused Code introduced by
The call to Update::data() has too many arguments starting with array('vars' => '', 'bod... 'compiled_body' => '').

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
27 1
            'vars' => '',
28
            'body' => '',
29
            'compiled_subject' => '',
30
            'compiled_body' => '',
31
        ]);
32
33 1
        return $query->execute();
34
    }
35
}
36