Completed
Push — master ( b87c44...b5d8bc )
by Tim
14:02
created

SysFileMetadataRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableName() 0 4 1
A findByFileUid() 0 13 2
1
<?php
2
3
/**
4
 * SysFileMetadata
5
 *
6
 */
7
8
namespace HDNET\Focuspoint\Domain\Repository;
9
10
use TYPO3\CMS\Core\Database\ConnectionPool;
11
use TYPO3\CMS\Core\Utility\GeneralUtility;
12
13
/**
14
 *  SysFileMetadata
15
 */
16
class SysFileMetadataRepository extends AbstractRawRepository
17
{
18
19
    /**
20
     * Get the tablename
21
     *
22
     * @return string
23
     */
24
    protected function getTableName(): string
25
    {
26
        return 'sys_file_metadata';
27
    }
28
29
    /**
30
     * Find by file
31
     *
32
     * @param int $fileUid
33
     * @return array|null
34
     */
35
    public function findByFileUid(int $fileUid)
36
    {
37
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->getTableName());
38
        $rows = $queryBuilder->select('*')
39
            ->from($this->getTableName())
40
            ->where(
41
                $queryBuilder->expr()->eq('file', $fileUid)
42
            )
43
            ->execute()
44
            ->fetchAll();
45
46
        return isset($rows[0]) ? $rows[0] : null;
47
    }
48
}
49