WhatsNewMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Audioplayer
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the LICENSE.md file.
8
 *
9
 * @author Marcel Scherello <[email protected]>
10
 * @author Arthur Schiwon <[email protected]>
11
 * @author Christoph Wurst <[email protected]>
12
 * @copyright 2020 Marcel Scherello
13
 */
14
15
namespace OCA\audioplayer\WhatsNew;
16
17
use OCP\AppFramework\Db\DoesNotExistException;
18
use OCP\AppFramework\Db\QBMapper;
19
use OCP\DB\QueryBuilder\IQueryBuilder;
20
use OCP\IDBConnection;
21
use Psr\Log\LoggerInterface;
22
23
class WhatsNewMapper extends QBMapper
24
{
25
    public const TABLE_NAME = 'audioplayer_whats_new';
26
    private $logger;
27
28
    public function __construct(
29
        LoggerInterface $logger,
30
        IDBConnection $db
31
    )
32
    {
33
        parent::__construct($db, self::TABLE_NAME);
34
        $this->logger = $logger;
35
    }
36
37
    /**
38
     * @throws DoesNotExistException
39
     */
40
    public function getChanges(string $version): WhatsNewResult
41
    {
42
        /* @var $qb IQueryBuilder */
43
        $qb = $this->db->getQueryBuilder();
44
        $result = $qb->select('*')
0 ignored issues
show
Deprecated Code introduced by
The function OCP\DB\QueryBuilder\IQueryBuilder::execute() has been deprecated: 22.0.0 Use executeQuery or executeStatement ( Ignorable by Annotation )

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

44
        $result = /** @scrutinizer ignore-deprecated */ $qb->select('*')

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
45
            ->from(self::TABLE_NAME)
46
            ->where($qb->expr()->eq('version', $qb->createNamedParameter($version)))
47
            ->execute();
48
49
        $data = $result->fetch();
50
        $result->closeCursor();
51
        if ($data === false) {
52
            throw new DoesNotExistException('Changes info is not present');
53
        }
54
        return WhatsNewResult::fromRow($data);
55
    }
56
}