Skip to content

Commit

Permalink
chore: polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed May 31, 2024
1 parent f834bce commit 144cf7e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Config/Server/Files/XHProf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Buggregator\Trap\Config\Server\Files;

use Buggregator\Trap\Service\Config\PhpIni;
use Buggregator\Trap\Service\FilesObserver\Filter\XHProf as Converter;
use Buggregator\Trap\Service\FilesObserver\Converter\XHProf as Converter;

/**
* @internal
Expand Down
1 change: 1 addition & 0 deletions src/Proto/Frame/Profiler/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ enum Type: string
{
case XHProf = 'XHProf';
case XDebug = 'XDebug';
case SPX = 'SPX';
}
5 changes: 4 additions & 1 deletion src/Service/Config/ConfigLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ private function injectValue(object $config, \ReflectionProperty $property, arra

/** @var mixed $value */
$value = match (true) {
$attribute instanceof XPath => @$this->xml?->xpath($attribute->path)[$attribute->key],
$attribute instanceof XPath => (static fn(?array $value, int $key): mixed => match (true) {
\array_key_exists($key, $value) => $value[$key],
default => null,
})($this->xml?->xpath($attribute->path), $attribute->key),
$attribute instanceof Env => $this->env[$attribute->name] ?? null,
$attribute instanceof InputOption => $this->inputOptions[$attribute->name] ?? null,
$attribute instanceof InputArgument => $this->inputArguments[$attribute->name] ?? null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

declare(strict_types=1);

namespace Buggregator\Trap\Service\FilesObserver\Filter;
namespace Buggregator\Trap\Service\FilesObserver\Converter;

use Buggregator\Trap\Logger;
use Buggregator\Trap\Proto\Frame\Profiler as ProfilerFrame;
use Buggregator\Trap\Service\FilesObserver\FileInfo;
use Buggregator\Trap\Service\FilesObserver\FrameConverter as FileFilterInterface;
Expand All @@ -13,6 +14,10 @@
*/
final class XHProf implements FileFilterInterface
{
public function __construct(

Check warning on line 17 in src/Service/FilesObserver/Converter/XHProf.php

View check run for this annotation

Codecov / codecov/patch

src/Service/FilesObserver/Converter/XHProf.php#L17

Added line #L17 was not covered by tests
private readonly Logger $logger,
) {}

Check warning on line 19 in src/Service/FilesObserver/Converter/XHProf.php

View check run for this annotation

Codecov / codecov/patch

src/Service/FilesObserver/Converter/XHProf.php#L19

Added line #L19 was not covered by tests

public function validate(FileInfo $file): bool

Check warning on line 21 in src/Service/FilesObserver/Converter/XHProf.php

View check run for this annotation

Codecov / codecov/patch

src/Service/FilesObserver/Converter/XHProf.php#L21

Added line #L21 was not covered by tests
{
return $file->getExtension() === 'xhprof';

Check warning on line 23 in src/Service/FilesObserver/Converter/XHProf.php

View check run for this annotation

Codecov / codecov/patch

src/Service/FilesObserver/Converter/XHProf.php#L23

Added line #L23 was not covered by tests
Expand Down Expand Up @@ -40,8 +45,7 @@ public function convert(FileInfo $file): \Traversable
),

Check warning on line 45 in src/Service/FilesObserver/Converter/XHProf.php

View check run for this annotation

Codecov / codecov/patch

src/Service/FilesObserver/Converter/XHProf.php#L36-L45

Added lines #L36 - L45 were not covered by tests
);
} catch (\Throwable $e) {
// todo log
\var_dump($e->getMessage());
$this->logger->exception($e);

Check warning on line 48 in src/Service/FilesObserver/Converter/XHProf.php

View check run for this annotation

Codecov / codecov/patch

src/Service/FilesObserver/Converter/XHProf.php#L47-L48

Added lines #L47 - L48 were not covered by tests
}
}

Expand Down Expand Up @@ -76,11 +80,11 @@ private function dataToPayload(array $data): array
'callee' => $callee,
'caller' => $caller,
'cost' => [
'cpu' => (int) $value['cpu'],
'ct' => (int) $value['ct'],
'mu' => (int) $value['mu'],
'pmu' => (int) $value['pmu'],
'wt' => (int) $value['wt'],
'cpu' => (int)$value['cpu'],
'ct' => (int)$value['ct'],
'mu' => (int)$value['mu'],
'pmu' => (int)$value['pmu'],
'wt' => (int)$value['wt'],
],
];

Check warning on line 89 in src/Service/FilesObserver/Converter/XHProf.php

View check run for this annotation

Codecov / codecov/patch

src/Service/FilesObserver/Converter/XHProf.php#L79-L89

Added lines #L79 - L89 were not covered by tests

Expand Down

0 comments on commit 144cf7e

Please sign in to comment.