Completed
Push — master ( 060b04...657701 )
by
unknown
04:35
created

StatusFlag   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 32
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A typeToStatus() 0 15 3
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Alessandro Cosentino <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @copyright Alessandro Cosentino 2012
11
 * @copyright Bernhard Posselt 2012, 2014
12
 */
13
14
namespace OCA\News\Db;
15
16
class StatusFlag {
17
    const UNREAD    = 0x02;
18
    const STARRED   = 0x04;
19
    const DELETED   = 0x08;
20
    const UPDATED   = 0x16;
21
22
23
	/**
24
	 * Get status for query
25
	 *
26
	 * @param int $type the type that should be turned into the status
27
	 * @param bool $showAll true if it should return all read items
28
	 * @return int the status for the database
29
	 */
30
    public function typeToStatus($type, $showAll){
31
        if($type === FeedType::STARRED){
32
            return self::STARRED;
33
        } else {
34
            $status = 0;
35
        }
36
37
        if($showAll){
38
            $status &= ~self::UNREAD;
39
        } else {
40
            $status |= self::UNREAD;
41
        }
42
43
        return $status;
44
    }
45
46
47
}