Skip to content

Commit

Permalink
chore: Bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Sep 24, 2024
1 parent 979b56a commit 44314a5
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 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 © 2024 Ambroise Maupate
Copyright © 2023 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": "6.4.*"
"symfony/stopwatch": "5.4.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
Expand All @@ -29,8 +29,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
"dev-master": "2.2.x-dev",
"dev-develop": "2.3.x-dev"
}
}
}
4 changes: 1 addition & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
parameters:
level: 7
level: max
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: 37 additions & 10 deletions src/CommonMark.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,41 @@

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(
private readonly MarkdownConverter $textConverter,
private readonly MarkdownConverter $textExtraConverter,
private readonly MarkdownConverter $lineConverter,
private readonly ?Stopwatch $stopwatch = null
MarkdownConverter $textConverter,
MarkdownConverter $textExtraConverter,
MarkdownConverter $lineConverter,
?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 '';
}
$this->stopwatch?->start(CommonMark::class . '::text');
if (null !== $this->stopwatch) {
$this->stopwatch->start(CommonMark::class . '::text');
}
$html = $this->textConverter->convert($markdown)->getContent();
$this->stopwatch?->stop(CommonMark::class . '::text');
if (null !== $this->stopwatch) {
$this->stopwatch->stop(CommonMark::class . '::text');
}
return $html;
}

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

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

final class MarkdownExtension extends AbstractExtension
{
public function __construct(private readonly MarkdownInterface $markdown)
private MarkdownInterface $markdown;

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

public function getFilters(): array
Expand Down

0 comments on commit 44314a5

Please sign in to comment.