Tag   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 51
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUniqueTagsByMaxId() 0 15 1
A getMaxTagId() 0 20 1
A _construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace IntegerNet\AsyncVarnish\Model\ResourceModel;
5
6
class Tag extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
7
{
8
9
    /**
10
     * DB Storage table name
11
     */
12
    const TABLE_NAME = 'integernet_async_varnish_tags';
13
14
    /* must be protected */
15
    protected function _construct() //phpcs:ignore MEQP2.PHP.ProtectedClassMember.FoundProtected
16
    {
17
        $this->_init(self::TABLE_NAME, 'entity_id');
18
    }
19
20
    public function getMaxTagId(int $limit):array
21
    {
22
        $connection = $this->getConnection();
23
24
        $subSetSelect = $connection->select()->from(
25
            self::TABLE_NAME,
0 ignored issues
show
Unused Code introduced by
The call to Magento\Framework\DB\Select::from() has too many arguments starting with self::TABLE_NAME. ( Ignorable by Annotation )

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

25
        $subSetSelect = $connection->select()->/** @scrutinizer ignore-call */ from(

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. Please note the @ignore annotation hint above.

Loading history...
26
            ['entity_id','tag']
27
        )->order(
28
            'entity_id',
29
            'ASC'
0 ignored issues
show
Unused Code introduced by
The call to Magento\Framework\DB\Select::order() has too many arguments starting with 'ASC'. ( Ignorable by Annotation )

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

29
        )->/** @scrutinizer ignore-call */ order(

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. Please note the @ignore annotation hint above.

Loading history...
30
        )->limit(
31
            $limit
32
        );
33
34
        $maxIdSelect = $connection->select()->from(
35
            $subSetSelect,
36
            ['max_id'=>'MAX(entity_id)']
37
        );
38
39
        return $connection->fetchRow($maxIdSelect);
40
    }
41
42
    public function getUniqueTagsByMaxId(int $maxId):array
43
    {
44
        $connection = $this->getConnection();
45
46
        $select = $connection->select()->from(
47
            ['main_table' => self::TABLE_NAME],
0 ignored issues
show
Unused Code introduced by
The call to Magento\Framework\DB\Select::from() has too many arguments starting with array('main_table' => self::TABLE_NAME). ( Ignorable by Annotation )

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

47
        $select = $connection->select()->/** @scrutinizer ignore-call */ from(

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. Please note the @ignore annotation hint above.

Loading history...
48
            ['tag']
49
        )->group(
50
            'tag'
51
        )->where(
52
            'main_table.entity_id <= ?',
53
            $maxId
54
        );
55
56
        return $connection->fetchAll($select);
57
    }
58
}
59