Skip to content

Commit 7e574a5

Browse files
author
Kirill Nesmeyanov
committed
Improve traceable type decorator formatting
1 parent 70110ac commit 7e574a5

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/Runtime/Repository/TypeDecorator/TraceableType.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace TypeLang\Mapper\Runtime\Repository\TypeDecorator;
66

77
use TypeLang\Mapper\Runtime\Context;
8+
use TypeLang\Mapper\Runtime\Context\Direction;
89
use TypeLang\Mapper\Runtime\Path\PathInterface;
910
use TypeLang\Mapper\Runtime\Tracing\TracerInterface;
1011
use TypeLang\Mapper\Type\TypeInterface;
@@ -29,22 +30,11 @@ public function __construct(
2930

3031
$inner = $this->getDecoratedType();
3132

32-
$this->name = self::getShortName($inner::class)
33-
. '#' . \spl_object_id($inner)
34-
. ' as "' . $this->definition . '"';
35-
}
36-
37-
/**
38-
* @param non-empty-string $fqn
39-
*
40-
* @return non-empty-string
41-
*/
42-
private static function getShortName(string $fqn): string
43-
{
44-
/** @var non-empty-list<non-empty-string> $parts */
45-
$parts = \explode('\\', $fqn);
46-
47-
return \end($parts);
33+
$this->name = \vsprintf('"%s" using %s#%d', [
34+
\addcslashes($this->definition, '"'),
35+
$inner::class,
36+
\spl_object_id($inner),
37+
]);
4838
}
4939

5040
private static function getPath(Context $context): PathInterface
@@ -55,10 +45,10 @@ private static function getPath(Context $context): PathInterface
5545
private static function getDirection(Context $context): Context\DirectionInterface
5646
{
5747
if ($context->isNormalization()) {
58-
return Context\Direction::Normalize;
48+
return Direction::Normalize;
5949
}
6050

61-
return Context\Direction::Denormalize;
51+
return Direction::Denormalize;
6252
}
6353

6454
public function match(mixed $value, Context $context): bool

0 commit comments

Comments
 (0)