ErrorMessage::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
/**
3
 * This field lets you put an error message box into your backend.
4
 *
5
 * <code>
6
 * ErrorMessage::create(
7
 *    $content = 'your error'
8
 * )
9
 * </code>
10
 *
11
 * or with the optional name parameter
12
 *
13
 * <code>
14
 * ErrorMessage::create(
15
 *    $content = 'your error',
16
 *    $name = 'FieldName'
17
 * )
18
 * </code>
19
 */
20
class ErrorMessage
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
21
{
22
    /**
23
     * @var string
24
     */
25
    public static $CSSClass = 'error';
26
27
    /**
28
     * creates a message box.
29
     *
30
     * @param string $message
31
     * @param string $name (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $name not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
32
     *
33
     * @return MessageBoxField
34
     */
35
    public static function create($message, $name = null)
36
    {
37
        return Message::generic($message, self::$CSSClass, $name);
38
    }
39
}
40