Passed
Push — master ( 2856b4...cf0423 )
by Felipe
10:02 queued 05:52
created

Postgres93   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 52
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getFunctions() 0 40 3
1
<?php
2
3
/**
4
 * PHPPgAdmin v6.0.0-beta.33
5
 */
6
7
namespace PHPPgAdmin\Database;
8
9
/**
10
 * @file
11
 * PostgreSQL 9.3 support
12
 */
13
class Postgres93 extends Postgres94
14
{
15
    public $major_version = 9.3;
16
17
    /**
18
     * Returns a list of all functions in the database.
19
     *
20
     * @param bool $all  If true, will find all available functions, if false just those in search path
0 ignored issues
show
Bug introduced by
The type PHPPgAdmin\Database\If 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...
21
     * @param                              $type If not null, will find all functions with return value = type
22
     *
23
     * @return \ADORecordSet All functions
24
     */
25
    public function getFunctions($all = false, $type = null)
26
    {
27
        if ($all) {
28
            $where    = 'pg_catalog.pg_function_is_visible(p.oid)';
29
            $distinct = 'DISTINCT ON (p.proname)';
30
31
            if ($type) {
32
                $where .= " AND p.prorettype = (select oid from pg_catalog.pg_type p where p.typname = 'trigger') ";
33
            }
34
        } else {
35
            $c_schema = $this->_schema;
36
            $this->clean($c_schema);
37
            $where    = "n.nspname = '{$c_schema}'";
38
            $distinct = '';
39
        }
40
41
        $sql = "
42
			SELECT
43
				{$distinct}
44
				p.oid AS prooid,
45
				p.proname,
46
				p.proretset,
47
				pg_catalog.format_type(p.prorettype, NULL) AS proresult,
48
				pg_catalog.oidvectortypes(p.proargtypes) AS proarguments,
49
				pl.lanname AS prolanguage,
50
				pg_catalog.obj_description(p.oid, 'pg_proc') AS procomment,
51
				p.proname || ' (' || pg_catalog.oidvectortypes(p.proargtypes) || ')' AS proproto,
52
				CASE WHEN p.proretset THEN 'setof ' ELSE '' END || pg_catalog.format_type(p.prorettype, NULL) AS proreturns,
53
				coalesce(u.rolname::text,p.proowner::text) AS proowner
54
55
			FROM pg_catalog.pg_proc p
56
				INNER JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
57
				INNER JOIN pg_catalog.pg_language pl ON pl.oid = p.prolang
58
				LEFT JOIN pg_catalog.pg_roles u ON u.oid = p.proowner
59
			WHERE NOT p.proisagg
60
				AND {$where}
61
			ORDER BY p.proname, proresult
62
			";
63
64
        return $this->selectSet($sql);
65
    }
66
}
67