Passed
Push — master ( 2715f7...fbc634 )
by Laurent
02:37
created

app_AccessManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 64
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A App() 0 3 1
A getAccess() 0 8 1
A setApp() 0 4 1
A getAccessCriterion() 0 3 1
1
<?php
2
//-------------------------------------------------------------------------
3
// OVIDENTIA http://www.ovidentia.org
4
// Ovidentia is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 2, or (at your option)
7
// any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
// See the GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17
// USA.
18
//-------------------------------------------------------------------------
19
/**
20
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
21
 * @copyright Copyright (c) 2009 by CANTICO ({@link http://www.cantico.fr})
22
 */
23
24
25
26
27
/**
28
 * The app_AccessManager class
29
 *
30
 * @method Func_App App()
31
 */
32
class app_AccessManager implements app_Object_Interface
33
{
34
    /**
35
     * @var Func_App
36
     */
37
    private $App = null;
0 ignored issues
show
introduced by
The private property $App is not used, and could be removed.
Loading history...
38
39
40
    /**
41
     * @param Func_App $app
42
     */
43
    public function __construct(Func_App $app)
44
    {
45
        $this->setApp($app);
46
    }
47
48
    /**
49
     * Forces the Func_App object to which this object is 'linked'.
50
     *
51
     * @param Func_App	$app
52
     * @return self
53
     */
54
    public function setApp(Func_App $app)
55
    {
56
        $this->app = $app;
0 ignored issues
show
Bug Best Practice introduced by
The property app does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
57
        return $this;
58
    }
59
60
    /**
61
     * Get APP object to use with this SET
62
     *
63
     * @return Func_App
64
     */
65
    public function App()
66
    {
67
        return $this->app;
68
    }
69
70
71
    /**
72
     *
73
     * @param app_RecordSet $recordSet
74
     * @param string        $accessType
75
     * @param int           $user
76
     */
77
    public function getAccessCriterion(app_RecordSet $recordSet, $accessType, $user = null)
0 ignored issues
show
Unused Code introduced by
The parameter $accessType is not used and could be removed. ( Ignorable by Annotation )

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

77
    public function getAccessCriterion(app_RecordSet $recordSet, /** @scrutinizer ignore-unused */ $accessType, $user = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

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

77
    public function getAccessCriterion(app_RecordSet $recordSet, $accessType, /** @scrutinizer ignore-unused */ $user = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
78
    {
79
        return $recordSet->none();
80
    }
81
82
    /**
83
     *
84
     * @param app_Record    $record
85
     * @param string        $accessType
86
     * @param int           $user
87
     */
88
    public function getAccess(app_Record $record, $accessType, $user = null)
89
    {
90
        $recordSet = $record->getParentSet();
91
        $criterion = $this->getAccessCriterion($recordSet, $accessType, $user);
92
93
        $matches = $recordSet->select($criterion->_AND_($recordSet->id->is($record->id)));
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on app_Record. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property id does not exist on app_RecordSet. Since you implemented __get, consider adding a @property annotation.
Loading history...
94
95
        return ($matches->count() !== 0);
96
    }
97
}
98