-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduces AbstractNormalizer class and clean-up all normalizers acco…
…rdingly
- Loading branch information
Showing
11 changed files
with
88 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of the Sarif-PHP-Converters package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Bartlett\Sarif\Converter\Normalizer; | ||
|
||
use Bartlett\Sarif\Contract\NormalizerInterface; | ||
|
||
use ArrayObject; | ||
use function in_array; | ||
|
||
/** | ||
* @author Laurent Laville | ||
* @since Release 1.0.0 | ||
*/ | ||
abstract class AbstractNormalizer implements NormalizerInterface | ||
{ | ||
public function getSupportedFormats(): array | ||
{ | ||
return [ | ||
NormalizerInterface::FORMAT_INTERNAL, | ||
]; | ||
} | ||
|
||
public function normalize($data, string $format, array $context): ?ArrayObject | ||
{ | ||
if (!in_array($format, $this->getSupportedFormats())) { | ||
return null; | ||
} | ||
|
||
// internal format (legacy) | ||
return new ArrayObject($this->fromInternal($data, $context)); | ||
} | ||
|
||
/** | ||
* @param mixed $data | ||
* @param array<string, mixed> $context Options available to the normalizer | ||
* @param array{}|array<string, string> $mapping From-To convert's mapping | ||
* @return array{files: mixed, errors: mixed, rules: mixed} | ||
*/ | ||
protected function fromInternal($data, array $context, array $mapping = []): array | ||
{ | ||
return [ | ||
'files' => [], | ||
'errors' => [], | ||
'rules' => [], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.