File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ class BaseEntityField implements EntityField
16
16
*/
17
17
protected $ name ;
18
18
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $ description ;
23
+
19
24
/**
20
25
* @var string
21
26
*/
@@ -59,6 +64,7 @@ class BaseEntityField implements EntityField
59
64
public function __construct (array $ p )
60
65
{
61
66
$ this ->name = $ this ->extractStringFromOptions ($ p , 'name ' , true );
67
+ $ this ->description = $ this ->extractStringFromOptions ($ p , 'description ' );
62
68
$ this ->type = $ this ->extractStringFromOptions ($ p , 'type ' , true );
63
69
$ this ->subType = $ this ->extractStringFromOptions ($ p , 'subType ' );
64
70
$ this ->length = isset ($ p ['length ' ]) ? (int ) $ p ['length ' ] : null ;
@@ -82,6 +88,14 @@ public function getName(): string
82
88
return $ this ->name ;
83
89
}
84
90
91
+ /**
92
+ * @inheritdoc
93
+ */
94
+ public function getDescription (): string
95
+ {
96
+ return $ this ->description ;
97
+ }
98
+
85
99
/**
86
100
* @inheritdoc
87
101
*/
Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ interface EntityField
16
16
*/
17
17
public function getName (): string ;
18
18
19
+ /**
20
+ * Возвращает описание поля.
21
+ *
22
+ * @return string
23
+ */
24
+ public function getDescription (): string ;
25
+
19
26
/**
20
27
* Возвращает тип поля.
21
28
*
Original file line number Diff line number Diff line change @@ -27,13 +27,27 @@ public function testGetName()
27
27
$ this ->assertSame ($ name , $ field ->getName ());
28
28
}
29
29
30
+ /**
31
+ * Проверяет, что объект правильно вернет описание поля.
32
+ */
33
+ public function testGetDescription ()
34
+ {
35
+ $ description = $ this ->createFakeData ()->word ;
36
+
37
+ $ field = $ this ->createField ([
38
+ 'description ' => $ description ,
39
+ ]);
40
+
41
+ $ this ->assertSame ($ description , $ field ->getDescription ());
42
+ }
43
+
30
44
/**
31
45
* Проверяет, что объект правильно выбросит исключение, если имя не задано.
32
46
*/
33
47
public function testEmptyNameException ()
34
48
{
35
49
$ this ->expectException (InvalidArgumentException::class);
36
- $ field = $ this ->createField ([
50
+ $ this ->createField ([
37
51
'name ' => null ,
38
52
]);
39
53
}
You can’t perform that action at this time.
0 commit comments