Skip to content

Commit 354dcdc

Browse files
committed
HP-2511 Add BehaviorInterface::description() method
1 parent 42d8d67 commit 354dcdc

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/product/behavior/Behavior.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ public function getTariffType(): TariffTypeInterface
1717
{
1818
return $this->tariffType;
1919
}
20+
21+
abstract public function description(): string;
2022
}

src/product/behavior/BehaviorInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,13 @@ interface BehaviorInterface
1212
public function setTariffType(TariffTypeInterface $tariffTypeName): void;
1313

1414
public function getTariffType(): TariffTypeInterface;
15+
16+
/**
17+
* Returns a description of the behavior formatted with HTML.
18+
* The description can be either static, or use the object values.
19+
*
20+
* It can be later used for UI or documentation purposes.
21+
* @return string
22+
*/
23+
public function description(): string;
1524
}

tests/unit/product/behavior/FakeBehavior.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44

55
class FakeBehavior extends TestBehavior
66
{
7-
7+
public function description(): string
8+
{
9+
return 'Fake behavior for testing scenarios';
10+
}
811
}

tests/unit/product/behavior/TestBehavior.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ public function getContext()
1717
{
1818
return $this->context;
1919
}
20+
21+
public function description(): string
22+
{
23+
return 'Test behavior for testing purposes';
24+
}
2025
}

0 commit comments

Comments
 (0)