| Total Complexity | 7 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | readonly class SkillTreeNodeTransformer implements DataTransformerInterface |
||
| 15 | { |
||
| 16 | public function __construct( |
||
| 19 | |||
| 20 | public function transform($object, string $to, array $context = []) |
||
| 21 | { |
||
| 22 | \assert($object instanceof Skill); |
||
| 23 | |||
| 24 | $leaf = new SkillTreeNode(); |
||
| 25 | $leaf->id = $object->getId(); |
||
| 26 | $leaf->title = $object->getTitle(); |
||
| 27 | $leaf->status = $object->getStatus(); |
||
| 28 | |||
| 29 | if (($shortCode = $object->getShortCode()) |
||
| 30 | && 'false' === $this->settingsManager->getSetting('skill.show_full_skill_name_on_skill_wheel') |
||
| 31 | ) { |
||
| 32 | $leaf->shortCode = $shortCode; |
||
| 33 | } |
||
| 34 | |||
| 35 | $leaf->children = []; |
||
| 36 | |||
| 37 | foreach ($object->getChildSkills() as $childSkill) { |
||
| 38 | $leaf->children[] = $this->transform($childSkill, $to, $context); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $leaf; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function supportsTransformation($data, string $to, array $context = []): bool |
||
| 47 | } |
||
| 48 | } |
||
| 49 |