Skip to content

Commit 1ae911c

Browse files
committed
Add new JobState struct
Also add php 8.4 to the buildmatrix
1 parent de362d2 commit 1ae911c

File tree

4 files changed

+118
-4
lines changed

4 files changed

+118
-4
lines changed

.github/workflows/php.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: ['ubuntu-latest']
15-
php: ['8.2', '8.3']
16-
continue-on-error: ${{ matrix.php == '8.3' }}
15+
php: ['8.2', '8.3', '8.4']
16+
continue-on-error: ${{ matrix.php == '8.4' }}
1717
steps:
1818
- uses: actions/checkout@v2
1919

@@ -27,15 +27,15 @@ jobs:
2727
run: composer validate
2828

2929
- name: Install dependencies
30-
if: ${{ matrix.php != '8.3' }}
30+
if: ${{ matrix.php != '8.4' }}
3131
uses: nick-invision/retry@v1
3232
with:
3333
timeout_minutes: 5
3434
max_attempts: 3
3535
command: composer update --no-interaction --no-progress
3636

3737
- name: Install Dependencies (ignore platform)
38-
if: ${{ matrix.php == '8.3' }}
38+
if: ${{ matrix.php == '8.4' }}
3939
uses: nick-invision/retry@v1
4040
with:
4141
timeout_minutes: 5

src/Struct/Generic/JobState.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Scn\EvalancheSoapStruct\Struct\Generic;
6+
7+
/**
8+
* Represents the state of a background job
9+
*
10+
* @package Scn\EvalancheSoapStruct\Struct\Generic
11+
*/
12+
class JobState implements JobStateInterface
13+
{
14+
/** @var string */
15+
private $id;
16+
17+
/** @var int */
18+
private $status;
19+
20+
/** @var string */
21+
private $statusDescription;
22+
23+
public function __construct(
24+
string $id = '',
25+
int $status = 0,
26+
string $statusDescription = '',
27+
) {
28+
$this->id = $id;
29+
$this->status = $status;
30+
$this->statusDescription = $statusDescription;
31+
}
32+
33+
/** @inheritDoc */
34+
public function getId(): string
35+
{
36+
return $this->id;
37+
}
38+
39+
/** @inheritDoc */
40+
public function getStatus(): int
41+
{
42+
return $this->status;
43+
}
44+
45+
/** @inheritDoc */
46+
public function getStatusDescription(): string
47+
{
48+
return $this->statusDescription;
49+
}
50+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Scn\EvalancheSoapStruct\Struct\Generic;
6+
7+
use Scn\EvalancheSoapStruct\Struct\StructInterface;
8+
9+
/**
10+
* @package Scn\EvalancheSoapStruct\Struct\Generic
11+
*/
12+
interface JobStateInterface extends StructInterface
13+
{
14+
/**
15+
* Returns the id of the background-job
16+
*/
17+
public function getId(): string;
18+
19+
/**
20+
* Returns the status-code of the background-job
21+
*/
22+
public function getStatus(): int;
23+
24+
/**
25+
* Returns a textual representation of the status-code
26+
*/
27+
public function getStatusDescription(): string;
28+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Scn\EvalancheSoapStruct\Struct\Generic;
6+
7+
use PHPUnit\Framework\TestCase;
8+
9+
class JobStateTest extends TestCase
10+
{
11+
private JobState $subject;
12+
13+
public function setUp(): void
14+
{
15+
$this->subject = new JobState(
16+
'some id',
17+
4,
18+
'some description',
19+
);
20+
}
21+
22+
public function testGetIdCanReturnString(): void
23+
{
24+
self::assertSame('some id', $this->subject->getId());
25+
}
26+
27+
public function testGetStatusCanReturnInt(): void
28+
{
29+
self::assertSame(4, $this->subject->getStatus());
30+
}
31+
32+
public function testGetStatusDescriptionCanReturnString(): void
33+
{
34+
self::assertSame('some description', $this->subject->getStatusDescription());
35+
}
36+
}

0 commit comments

Comments
 (0)