Skip to content

Commit

Permalink
Merge pull request #17 from Jaimies/master
Browse files Browse the repository at this point in the history
Add "RFF" Segment
  • Loading branch information
Chemaclass committed Oct 30, 2022
2 parents 68fca55 + 39e04cb commit a938872
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Segments/RFFReference.php
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace EdifactParser\Segments;

/** @psalm-immutable */
class RFFReference implements SegmentInterface
{
public function __construct(private array $rawValues)
{
}

public function tag(): string
{
return self::class;
}
public function subId(): string
{
return $this->rawValues[1][0];
}
public function rawValues(): array
{
return $this->rawValues;
}
}
1 change: 1 addition & 0 deletions src/Segments/SegmentFactory.php
Expand Up @@ -23,6 +23,7 @@ final class SegmentFactory implements SegmentFactoryInterface
'PCI' => PCIPackageId::class,
'BGM' => BGMBeginningOfMessage::class,
'UNT' => UNTMessageFooter::class,
'RFF' => RFFReference::class,
];

private const TAG_LENGTH = 3;
Expand Down
24 changes: 24 additions & 0 deletions tests/Unit/Segments/RFFReferenceTest.php
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace EdifactParser\Tests\Unit\Segments;

use EdifactParser\Segments\RFFReference;
use PHPUnit\Framework\TestCase;

class RFFReferenceTest extends TestCase
{
/**
* @test
*/
public function segment_values(): void
{
$rawValues = ['RFF', ['ADE', '123413287423784']];
$segment = new RFFReference($rawValues);

self::assertEquals(RFFReference::class, $segment->tag());
self::assertEquals('ADE', $segment->subId());
self::assertEquals($rawValues, $segment->rawValues());
}
}

0 comments on commit a938872

Please sign in to comment.