Completed
Push — master ( 212c12...c53449 )
by Jonathan
20:38 queued 10:31
created

ucnotify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Uccello\Core\Models\Module;
4
5
if (!function_exists('uccello')) {
6
    /**
7
     * Return an instance of Uccello\Core\Helpers\Uccello
8
     *
9
     * @return void
10
     */
11
    function uccello()
12
    {
13
        return app('uccello');
0 ignored issues
show
Bug Best Practice introduced by
The expression return app('uccello') returns the type Uccello\Core\Facades\Uccello which is incompatible with the documented return type void.
Loading history...
14
    }
15
}
16
17
if (!function_exists('uctrans')) {
18
    /**
19
     * Retrieve prefix and translate the given message. If the default translation does not exist try to find a fallback one.
20
     *
21
     * @param  string  $key
22
     * @param  Module|null  $module
23
     * @param  array   $replace
24
     * @param  string  $locale
25
     * @return \Illuminate\Contracts\Translation\Translator|string|array|null
26
     *
27
     * @see Uccello\Core\Helpers\Uccello
28
     */
29
    function uctrans($key = null, ? Module $module = null, $replace = [ ], $locale = null)
30
    {
31
        return app('uccello')->trans($key, $module, $replace, $locale);
0 ignored issues
show
Bug introduced by
The method trans() does not exist on Uccello\Core\Facades\Uccello. ( Ignorable by Annotation )

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

31
        return app('uccello')->/** @scrutinizer ignore-call */ trans($key, $module, $replace, $locale);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
    }
33
}
34
35
if (!function_exists('ucmodule')) {
36
    /**
37
     * Get a module instance by name or id
38
     *
39
     * @param string|int $name
40
     * @return Module|null
41
     */
42
    function ucmodule($nameOrId): ?Module
43
    {
44
        return app('uccello')->getModule($nameOrId);
0 ignored issues
show
Bug introduced by
The method getModule() does not exist on Uccello\Core\Facades\Uccello. ( Ignorable by Annotation )

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

44
        return app('uccello')->/** @scrutinizer ignore-call */ getModule($nameOrId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
    }
46
}
47
48
if (!function_exists('ucroute')) {
49
    /**
50
     * Makes route automaticaly and add domain and module parameter.
51
     *
52
     * @param array|string $name
53
     * @param Domain|string|null $domain
54
     * @param Module|string|null $module
55
     * @param mixed $parameters
56
     * @param boolean $absolute
57
     * @return string
58
     */
59
    function ucroute($name, $domain = null, $module = null, $parameters = [ ], $absolute = true) : string
60
    {
61
        return app('uccello')->route($name, $domain, $module, $parameters, $absolute);
0 ignored issues
show
Bug introduced by
The method route() does not exist on Uccello\Core\Facades\Uccello. ( Ignorable by Annotation )

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

61
        return app('uccello')->/** @scrutinizer ignore-call */ route($name, $domain, $module, $parameters, $absolute);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
62
    }
63
}
64
65
if (!function_exists('uclog')) {
66
    /**
67
     * Use Debugbar to log data.
68
     *
69
     * @param mixed $data
70
     * @return void
71
     */
72
    function uclog($data)
73
    {
74
        \Debugbar::info($data);
0 ignored issues
show
Bug introduced by
The type Debugbar 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...
75
    }
76
}
77
78
if (!function_exists('uitype')) {
79
    /**
80
     * Get an uitype instance by name or id
81
     *
82
     * @param string|int $nameOrId
83
     * @return Uitype|null
0 ignored issues
show
Bug introduced by
The type Uitype 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...
84
     */
85
    function uitype($nameOrId)
86
    {
87
        return app('uccello')->getUitype($nameOrId);
0 ignored issues
show
Bug introduced by
The method getUitype() does not exist on Uccello\Core\Facades\Uccello. ( Ignorable by Annotation )

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

87
        return app('uccello')->/** @scrutinizer ignore-call */ getUitype($nameOrId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
    }
89
}
90
91
if (!function_exists('displaytype')) {
92
    /**
93
     * Get a display type instance by name or id
94
     *
95
     * @param string|int $nameOrId
96
     * @return Displaytype|null
0 ignored issues
show
Bug introduced by
The type Displaytype 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...
97
     */
98
    function displaytype($nameOrId)
99
    {
100
        return app('uccello')->getDisplaytype($nameOrId);
0 ignored issues
show
Bug introduced by
The method getDisplaytype() does not exist on Uccello\Core\Facades\Uccello. ( Ignorable by Annotation )

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

100
        return app('uccello')->/** @scrutinizer ignore-call */ getDisplaytype($nameOrId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
101
    }
102
}
103
104
if (!function_exists('capability')) {
105
    /**
106
     * Get a capability instance by name or id
107
     *
108
     * @param string|int $nameOrId
109
     * @return Capabillity|null
0 ignored issues
show
Bug introduced by
The type Capabillity 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...
110
     */
111
    function capability($nameOrId)
112
    {
113
        return app('uccello')->getCapability($nameOrId);
0 ignored issues
show
Bug introduced by
The method getCapability() does not exist on Uccello\Core\Facades\Uccello. ( Ignorable by Annotation )

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

113
        return app('uccello')->/** @scrutinizer ignore-call */ getCapability($nameOrId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
114
    }
115
}
116
117
if (!function_exists('ucasset')) {
118
    /**
119
     * Get complete path to asset
120
     *
121
     * @param string $path
122
     * @param string $package
123
     * @return void
124
     */
125
    function ucasset($path, $package = 'uccello/uccello')
126
    {
127
        return asset("vendor/$package/$path");
0 ignored issues
show
Bug Best Practice introduced by
The expression return asset('vendor/'.$package.'/'.$path) returns the type string which is incompatible with the documented return type void.
Loading history...
128
    }
129
}
130
131
if (!function_exists('ucattribute')) {
132
    /**
133
     * Returns a record attribute value.
134
     * It is able to follow a complex path according to models definition (e.g. 'domain.parent.name')
135
     *
136
     * @param Object $record
137
     * @param string $attribute
138
     * @return string|Object|Array|null
139
     */
140
    function ucattribute($record, $attribute)
141
    {
142
        return app('uccello')->getRecordAttribute($record, $attribute);
0 ignored issues
show
Bug introduced by
The method getRecordAttribute() does not exist on Uccello\Core\Facades\Uccello. ( Ignorable by Annotation )

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

142
        return app('uccello')->/** @scrutinizer ignore-call */ getRecordAttribute($record, $attribute);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
143
    }
144
}
145
146
if (!function_exists('ucnotify')) {
147
    /**
148
     * Uses flash session to display a notification.
149
     *
150
     * @param string $message
151
     * @param string $type
152
     * @return void
153
     */
154
    function ucnotify($message, $type = 'info') {
155
        session()->flash('notification-'.$type, $message);
156
    }
157
}