Skip to content

Commit

Permalink
chore: Bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Feb 10, 2025
1 parent 575d99d commit 0865d19
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 46 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2023 Ambroise Maupate
Copyright © 2024 Ambroise Maupate

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"league/commonmark": "^2.2.0",
"twig/twig": "^3.1",
"doctrine/collections": ">=1.6",
"symfony/stopwatch": "5.4.*"
"symfony/stopwatch": "6.4.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
Expand All @@ -29,8 +29,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev",
"dev-develop": "2.3.x-dev"
"dev-master": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
}
}
}
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
parameters:
level: max
level: 7
paths:
- src
excludePaths:
- */node_modules/*
- */bower_components/*
- */static/*
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Instantiated class Memcached not found#'
- '#Instantiated class Redis not found#'
reportUnmatchedIgnoredErrors: false
47 changes: 10 additions & 37 deletions src/CommonMark.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,22 @@

final class CommonMark implements MarkdownInterface
{
private ?Stopwatch $stopwatch;
private MarkdownConverter $textConverter;
private MarkdownConverter $lineConverter;
private MarkdownConverter $textExtraConverter;

/**
* @param MarkdownConverter $textConverter
* @param MarkdownConverter $textExtraConverter
* @param MarkdownConverter $lineConverter
* @param Stopwatch|null $stopwatch
*/
public function __construct(
MarkdownConverter $textConverter,
MarkdownConverter $textExtraConverter,
MarkdownConverter $lineConverter,
?Stopwatch $stopwatch = null
private readonly MarkdownConverter $textConverter,
private readonly MarkdownConverter $textExtraConverter,
private readonly MarkdownConverter $lineConverter,
private readonly ?Stopwatch $stopwatch = null
) {
$this->textConverter = $textConverter;
$this->textExtraConverter = $textExtraConverter;
$this->lineConverter = $lineConverter;
$this->stopwatch = $stopwatch;
}

public function text(string $markdown = null): string
{
if (null === $markdown) {
return '';
}
if (null !== $this->stopwatch) {
$this->stopwatch->start(CommonMark::class . '::text');
}
$this->stopwatch?->start(CommonMark::class . '::text');
$html = $this->textConverter->convert($markdown)->getContent();
if (null !== $this->stopwatch) {
$this->stopwatch->stop(CommonMark::class . '::text');
}
$this->stopwatch?->stop(CommonMark::class . '::text');
return $html;
}

Expand All @@ -52,13 +33,9 @@ public function textExtra(string $markdown = null): string
if (null === $markdown) {
return '';
}
if (null !== $this->stopwatch) {
$this->stopwatch->start(CommonMark::class . '::textExtra');
}
$this->stopwatch?->start(CommonMark::class . '::textExtra');
$html = $this->textExtraConverter->convert($markdown)->getContent();
if (null !== $this->stopwatch) {
$this->stopwatch->stop(CommonMark::class . '::textExtra');
}
$this->stopwatch?->stop(CommonMark::class . '::textExtra');
return $html;
}

Expand All @@ -67,13 +44,9 @@ public function line(string $markdown = null): string
if (null === $markdown) {
return '';
}
if (null !== $this->stopwatch) {
$this->stopwatch->start(CommonMark::class . '::line');
}
$this->stopwatch?->start(CommonMark::class . '::line');
$html = $this->lineConverter->convert($markdown)->getContent();
if (null !== $this->stopwatch) {
$this->stopwatch->stop(CommonMark::class . '::line');
}
$this->stopwatch?->stop(CommonMark::class . '::line');
return $html;
}
}
5 changes: 1 addition & 4 deletions src/Twig/MarkdownExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

final class MarkdownExtension extends AbstractExtension
{
private MarkdownInterface $markdown;

public function __construct(MarkdownInterface $markdown)
public function __construct(private readonly MarkdownInterface $markdown)
{
$this->markdown = $markdown;
}

public function getFilters(): array
Expand Down

0 comments on commit 0865d19

Please sign in to comment.