Passed
Push — master ( a7cb98...edba21 )
by Fabrice
03:13
created

ExtractorLimitAbstract::getNumRecords()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/*
4
 * This file is part of YaEtl
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\YaEtl\Extractors;
11
12
/**
13
 * Class ExtractorLimitAbstract
14
 */
15
abstract class ExtractorLimitAbstract extends ExtractorAbstract implements ExtractorLimitInterface
16
{
17
    /**
18
     * Total number of records to fetch
19
     *
20
     * @var int
21
     */
22
    protected $limit;
23
24
    /**
25
     * Set extract limit
26
     *
27
     * @param int|null $limit
28
     *
29
     * @return static
30
     */
31
    public function setLimit(?int $limit): ExtractorLimitInterface
32
    {
33
        $this->limit = $limit;
34
35
        return $this;
36
    }
37
38
    /**
39
     * Get current limit
40
     *
41
     * @return int|null
42
     */
43
    public function getLimit(): ? int
44
    {
45
        return $this->limit;
46
    }
47
48
    /**
49
     * Tells if limit is reached already
50
     *
51
     * @return bool true if limit is reached
52
     */
53
    public function isLimitReached(): bool
54
    {
55
        return $this->limit && ($this->numRecords >= $this->limit);
56
    }
57
}
58