Issues (496)

lib/WhatsNew/WhatsNewMapper.php (5 issues)

Labels
Severity
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Analytics
5
 *
6
 * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
7
 * SPDX-License-Identifier: AGPL-3.0-or-later
8
 */
9
10
namespace OCA\Analytics\WhatsNew;
11
12
use OCP\AppFramework\Db\DoesNotExistException;
0 ignored issues
show
The type OCP\AppFramework\Db\DoesNotExistException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use OCP\AppFramework\Db\QBMapper;
0 ignored issues
show
The type OCP\AppFramework\Db\QBMapper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use OCP\DB\QueryBuilder\IQueryBuilder;
0 ignored issues
show
The type OCP\DB\QueryBuilder\IQueryBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use OCP\IDBConnection;
0 ignored issues
show
The type OCP\IDBConnection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Psr\Log\LoggerInterface;
0 ignored issues
show
The type Psr\Log\LoggerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
18
class WhatsNewMapper extends QBMapper
19
{
20
    public const TABLE_NAME = 'analytics_whats_new';
21
    private $logger;
22
23
    public function __construct(
24
        LoggerInterface $logger,
25
        IDBConnection $db
26
    )
27
    {
28
        parent::__construct($db, self::TABLE_NAME);
29
        $this->logger = $logger;
30
    }
31
32
    /**
33
     * @throws DoesNotExistException
34
     */
35
    public function getChanges(string $version): WhatsNewResult
36
    {
37
        /* @var $qb IQueryBuilder */
38
        $qb = $this->db->getQueryBuilder();
39
        $result = $qb->select('*')
40
            ->from(self::TABLE_NAME)
41
            ->where($qb->expr()->eq('version', $qb->createNamedParameter($version)))
42
            ->execute();
43
44
        $data = $result->fetch();
45
        $result->closeCursor();
46
        if ($data === false) {
47
            throw new DoesNotExistException('Changes info is not present');
48
        }
49
        return WhatsNewResult::fromRow($data);
50
    }
51
}