Skip to content

Commit 2d5dc2f

Browse files
committed
Named blob VO
1 parent 3477f6b commit 2d5dc2f

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

src/VO/NamedBlob.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Github\VO;
4+
5+
use React\Stream\ReadableStreamInterface;
6+
7+
final class NamedBlob
8+
{
9+
/**
10+
* @var string
11+
*/
12+
private $path;
13+
14+
/**
15+
* @var string
16+
*/
17+
private $mode;
18+
19+
/**
20+
* @var string
21+
*/
22+
private $type;
23+
24+
/**
25+
* @var string|null
26+
*/
27+
private $sha;
28+
29+
/**
30+
* @var ReadableStreamInterface|null
31+
*/
32+
private $content;
33+
34+
/**
35+
* @param string $path
36+
* @param string $mode
37+
* @param string $type
38+
* @param string|null $sha
39+
* @param ReadableStreamInterface|null $content
40+
* @throws \Exception
41+
*/
42+
public function __construct(string $path, string $mode, string $type, ?string $sha, ?ReadableStreamInterface $content)
43+
{
44+
$this->path = $path;
45+
$this->mode = $mode;
46+
$this->type = $type;
47+
$this->sha = $sha;
48+
$this->content = $content;
49+
50+
if ($this->sha === null && $this->content === null) {
51+
throw new \Exception('Only `sha` or `content` can be `null` not both');
52+
}
53+
}
54+
55+
/**
56+
* @return string
57+
*/
58+
public function getPath(): string
59+
{
60+
return $this->path;
61+
}
62+
63+
/**
64+
* @return string
65+
*/
66+
public function getMode(): string
67+
{
68+
return $this->mode;
69+
}
70+
71+
/**
72+
* @return string
73+
*/
74+
public function getType(): string
75+
{
76+
return $this->type;
77+
}
78+
79+
/**
80+
* @return string|null
81+
*/
82+
public function getSha(): ?string
83+
{
84+
return $this->sha;
85+
}
86+
87+
/**
88+
* @return ReadableStreamInterface|null
89+
*/
90+
public function getContent(): ?ReadableStreamInterface
91+
{
92+
return $this->content;
93+
}
94+
}

0 commit comments

Comments
 (0)