RecordsTrait::reduceOldSessions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace ByTIC\Payments\Models\PurchaseSessions\Traits\Cleanup;
4
5
use Nip\Database\Query\Delete;
6
7
/**
8
 * Trait RecordsTrait
9
 * @package ByTIC\Payments\Models\PurchaseSessions\Traits\Cleanup
10
 */
11
trait RecordsTrait
12
{
13
    protected $createdDateField = 'created';
14
    protected $daysToKeepData = 365;
15
16
    /**
17
     * @return \Nip\Database\Result
18
     */
19
    public function reduceOldSessions()
20
    {
21
        /** @var Delete $query */
22
        $query = $this->newDeleteQuery();
0 ignored issues
show
Bug introduced by
It seems like newDeleteQuery() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        $query = $this->newDeleteQuery();
Loading history...
23
        $query->where(
24
            '`' . $this->createdDateField . '` <= DATE_SUB(CURRENT_DATE(), INTERVAL ' . $this->daysToKeepData . ' DAY)'
25
        );
26
27
        return $query->execute();
28
    }
29
}
30