Skip to content

Commit 55b1285

Browse files
committed
add missing video types
1 parent 06606c6 commit 55b1285

File tree

4 files changed

+231
-0
lines changed

4 files changed

+231
-0
lines changed

src/Types/Video/Episode.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace Astrotomic\OpenGraph\Types\Video;
4+
5+
use Astrotomic\OpenGraph\Type;
6+
use DateTime;
7+
8+
class Episode extends Type
9+
{
10+
protected const PREFIX = 'video';
11+
12+
protected string $type = 'video.episode';
13+
14+
public function series(string $url)
15+
{
16+
$this->setProperty(self::PREFIX, 'series', $url);
17+
18+
return $this;
19+
}
20+
21+
public function actor(string $url, ?string $role = null)
22+
{
23+
$this->addProperty(self::PREFIX, 'actor', $url);
24+
$this->when($role, fn(Movie $movie) => $movie->addProperty(self::PREFIX, 'actor:role', $role));
25+
26+
return $this;
27+
}
28+
29+
public function director(string $url)
30+
{
31+
$this->addProperty(self::PREFIX, 'director', $url);
32+
33+
return $this;
34+
}
35+
36+
public function writer(string $url)
37+
{
38+
$this->addProperty(self::PREFIX, 'writer', $url);
39+
40+
return $this;
41+
}
42+
43+
public function duration(int $seconds)
44+
{
45+
$this->setProperty(self::PREFIX, 'duration', $seconds);
46+
47+
return $this;
48+
}
49+
50+
public function releasedAt(DateTime $releaseDate)
51+
{
52+
$this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
53+
54+
return $this;
55+
}
56+
57+
public function tag(string $tag)
58+
{
59+
$this->addProperty(self::PREFIX, 'tag', $tag);
60+
61+
return $this;
62+
}
63+
}

src/Types/Video/Movie.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Astrotomic\OpenGraph\Types\Video;
4+
5+
use Astrotomic\OpenGraph\Type;
6+
use DateTime;
7+
8+
class Movie extends Type
9+
{
10+
protected const PREFIX = 'video';
11+
12+
protected string $type = 'video.movie';
13+
14+
public function actor(string $url, ?string $role = null)
15+
{
16+
$this->addProperty(self::PREFIX, 'actor', $url);
17+
$this->when($role, fn(Movie $movie) => $movie->addProperty(self::PREFIX, 'actor:role', $role));
18+
19+
return $this;
20+
}
21+
22+
public function director(string $url)
23+
{
24+
$this->addProperty(self::PREFIX, 'director', $url);
25+
26+
return $this;
27+
}
28+
29+
public function writer(string $url)
30+
{
31+
$this->addProperty(self::PREFIX, 'writer', $url);
32+
33+
return $this;
34+
}
35+
36+
public function duration(int $seconds)
37+
{
38+
$this->setProperty(self::PREFIX, 'duration', $seconds);
39+
40+
return $this;
41+
}
42+
43+
public function releasedAt(DateTime $releaseDate)
44+
{
45+
$this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
46+
47+
return $this;
48+
}
49+
50+
public function tag(string $tag)
51+
{
52+
$this->addProperty(self::PREFIX, 'tag', $tag);
53+
54+
return $this;
55+
}
56+
}

src/Types/Video/Other.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Astrotomic\OpenGraph\Types\Video;
4+
5+
use Astrotomic\OpenGraph\Type;
6+
use DateTime;
7+
8+
class Other extends Type
9+
{
10+
protected const PREFIX = 'video';
11+
12+
protected string $type = 'video.other';
13+
14+
public function actor(string $url, ?string $role = null)
15+
{
16+
$this->addProperty(self::PREFIX, 'actor', $url);
17+
$this->when($role, fn(Movie $movie) => $movie->addProperty(self::PREFIX, 'actor:role', $role));
18+
19+
return $this;
20+
}
21+
22+
public function director(string $url)
23+
{
24+
$this->addProperty(self::PREFIX, 'director', $url);
25+
26+
return $this;
27+
}
28+
29+
public function writer(string $url)
30+
{
31+
$this->addProperty(self::PREFIX, 'writer', $url);
32+
33+
return $this;
34+
}
35+
36+
public function duration(int $seconds)
37+
{
38+
$this->setProperty(self::PREFIX, 'duration', $seconds);
39+
40+
return $this;
41+
}
42+
43+
public function releasedAt(DateTime $releaseDate)
44+
{
45+
$this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
46+
47+
return $this;
48+
}
49+
50+
public function tag(string $tag)
51+
{
52+
$this->addProperty(self::PREFIX, 'tag', $tag);
53+
54+
return $this;
55+
}
56+
}

src/Types/Video/TvShow.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Astrotomic\OpenGraph\Types\Video;
4+
5+
use Astrotomic\OpenGraph\Type;
6+
use DateTime;
7+
8+
class TvShow extends Type
9+
{
10+
protected const PREFIX = 'video';
11+
12+
protected string $type = 'video.tv_show';
13+
14+
public function actor(string $url, ?string $role = null)
15+
{
16+
$this->addProperty(self::PREFIX, 'actor', $url);
17+
$this->when($role, fn(Movie $movie) => $movie->addProperty(self::PREFIX, 'actor:role', $role));
18+
19+
return $this;
20+
}
21+
22+
public function director(string $url)
23+
{
24+
$this->addProperty(self::PREFIX, 'director', $url);
25+
26+
return $this;
27+
}
28+
29+
public function writer(string $url)
30+
{
31+
$this->addProperty(self::PREFIX, 'writer', $url);
32+
33+
return $this;
34+
}
35+
36+
public function duration(int $seconds)
37+
{
38+
$this->setProperty(self::PREFIX, 'duration', $seconds);
39+
40+
return $this;
41+
}
42+
43+
public function releasedAt(DateTime $releaseDate)
44+
{
45+
$this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
46+
47+
return $this;
48+
}
49+
50+
public function tag(string $tag)
51+
{
52+
$this->addProperty(self::PREFIX, 'tag', $tag);
53+
54+
return $this;
55+
}
56+
}

0 commit comments

Comments
 (0)