Skip to content

Commit 539dc97

Browse files
author
yggverse
committed
format toString separators
1 parent 441dc1e commit 539dc97

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

src/Entity/Code.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ public function isInline(): bool
5858

5959
public function toString(): string
6060
{
61-
return self::TAG . $this->_alt . ($this->_inline ? self::TAG : null);
61+
return $this->_inline ? sprintf(
62+
'%s%s%s',
63+
self::TAG,
64+
$this->_alt,
65+
self::TAG
66+
) : trim(
67+
sprintf(
68+
'%s %s',
69+
self::TAG,
70+
$this->_alt
71+
)
72+
);
6273
}
6374
}

src/Entity/Header.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ public function getText(): ?string
6565

6666
public function toString(): string
6767
{
68-
return str_repeat(
69-
self::TAG,
70-
$this->_level
71-
) . $this->_text;
68+
return trim(
69+
sprintf(
70+
'%s %s',
71+
str_repeat(
72+
self::TAG,
73+
$this->_level
74+
),
75+
$this->_text
76+
)
77+
);
7278
}
7379
}

src/Entity/Link.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ public function toString(): string
116116
$parts[] = $alt;
117117
}
118118

119-
return implode(
120-
' ',
121-
$parts
119+
return trim(
120+
implode(
121+
' ',
122+
$parts
123+
)
122124
);
123125
}
124126
}

src/Entity/Listing.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public function Item(): ?string
3939

4040
public function toString(): string
4141
{
42-
return self::TAG . ' ' . $this->_item;
42+
return trim(
43+
sprintf(
44+
'%s %s',
45+
self::TAG,
46+
$this->_item
47+
)
48+
);
4349
}
4450
}

src/Entity/Quote.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public function getText(): ?string
3939

4040
public function toString(): string
4141
{
42-
return self::TAG . ' ' . $this->_text;
42+
return trim(
43+
sprintf(
44+
'%s %s',
45+
self::TAG,
46+
$this->_text
47+
)
48+
);
4349
}
4450
}

0 commit comments

Comments
 (0)