ThreemaGateway_Model_Keystore   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findPublicKey() 0 15 3
1
<?php
2
/**
3
 * Model for Threema database keystore.
4
 *
5
 * @package ThreemaGateway
6
 * @author rugk
7
 * @copyright Copyright (c) 2015-2016 rugk
8
 * @license MIT
9
 */
10
11
class ThreemaGateway_Model_Keystore extends XenForo_Model
12
{
13
    /**
14
     * @var string database table name
15
     */
16
    const DB_TABLE = 'xf_threemagw_keystore';
17
18
    /**
19
     * Find public key. Returns false if the public key is not found in the
20
     * store.
21
     *
22
     * @param string $threemaId
23
     *
24
     * @return null|string
25
     */
26
    public function findPublicKey($threemaId)
27
    {
28
        /** @var mixed $result result of SQL query */
29
        $result = $this->_getDb()->fetchRow(
30
            $this->_getDb()->select()
31
                ->from(self::DB_TABLE)
32
                ->where('threema_id = ?', $threemaId)
33
        );
34
35
        if (is_array($result) && array_key_exists('public_key', $result)) {
36
            return (string) $result['public_key'];
37
        }
38
39
        return null;
40
    }
41
}
42