Passed
Pull Request — master (#405)
by Nic
10:58
created

ClearPasswordLogTask::getLogs()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Dynamic\FoxyStripe\Tasks;
4
5
use SilverStripe\Dev\BuildTask;
6
use SilverStripe\ORM\DB;
7
8
/**
9
 * Class ClearPasswordLogTask
10
 * @package Dynamic\FoxyStripe\Tasks
11
 */
12
class ClearPasswordLogTask extends BuildTask
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $title = 'Foxy - Clear Password Log Task';
18
19
    /**
20
     * @var string
21
     */
22
    private static $segment = 'foxy-clear-password-log-task';
0 ignored issues
show
introduced by
The private property $segment is not used, and could be removed.
Loading history...
23
24
    /**
25
     * @param \SilverStripe\Control\HTTPRequest $request
26
     */
27
    public function run($request)
28
    {
29
        $this->resetLog();
30
    }
31
32
    /**
33
     *
34
     */
35
    protected function resetLog()
36
    {
37
        foreach ($this->getLogs() as $log) {
38
            DB::prepared_query("DELETE FROM `MemberPassword` WHERE `ID` = ?", [$log['ID']]);
39
        }
40
    }
41
42
    /**
43
     * @return \Generator
44
     */
45
    protected function getLogs()
46
    {
47
        foreach (DB::query("Select * FROM `MemberPassword`") as $passwordLog) {
48
            yield $passwordLog;
49
        }
50
    }
51
}
52