├── .editorconfig
├── .github
├── dependabot.yml
└── workflows
│ ├── pest.yml
│ └── pint.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── composer.json
└── src
├── BaseObject.php
├── OpenGraph.php
├── Property.php
├── StructuredProperties
├── Audio.php
├── Image.php
├── StructuredProperty.php
└── Video.php
├── Twitter.php
├── TwitterProperty.php
├── TwitterType.php
├── Type.php
└── Types
├── Article.php
├── Book.php
├── Music
├── Album.php
├── Playlist.php
├── RadioStation.php
└── Song.php
├── Profile.php
├── Twitter
├── App.php
├── Player.php
├── Summary.php
└── SummaryLargeImage.php
├── Video
├── Episode.php
├── Movie.php
├── Other.php
└── TvShow.php
└── Website.php
/.editorconfig:
--------------------------------------------------------------------------------
1 | ; This file is for unifying the coding style for different editors and IDEs.
2 | ; More information at http://editorconfig.org
3 |
4 | root = true
5 |
6 | [*]
7 | charset = utf-8
8 | indent_size = 4
9 | indent_style = space
10 | end_of_line = lf
11 | insert_final_newline = true
12 | trim_trailing_whitespace = true
13 |
14 | [*.md]
15 | trim_trailing_whitespace = false
16 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "composer"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | open-pull-requests-limit: 10
8 | reviewers:
9 | - "Gummibeer"
10 | - package-ecosystem: "github-actions"
11 | directory: "/"
12 | schedule:
13 | interval: "daily"
14 | reviewers:
15 | - "Gummibeer"
16 |
--------------------------------------------------------------------------------
/.github/workflows/pest.yml:
--------------------------------------------------------------------------------
1 | name: pest
2 |
3 | on:
4 | push:
5 | pull_request:
6 |
7 | jobs:
8 | test:
9 | name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
10 | runs-on: ubuntu-latest
11 | timeout-minutes: 15
12 | strategy:
13 | matrix:
14 | php: ['8.1', '8.2']
15 | dependency-version: [prefer-lowest, prefer-stable]
16 | steps:
17 | - uses: actions/checkout@v4
18 | - uses: shivammathur/setup-php@v2
19 | with:
20 | php-version: ${{ matrix.php }}
21 | extensions: mbstring, json
22 | - run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
23 | - run: vendor/bin/pest
24 |
--------------------------------------------------------------------------------
/.github/workflows/pint.yml:
--------------------------------------------------------------------------------
1 | name: pint
2 |
3 | on:
4 | push:
5 | pull_request:
6 |
7 | jobs:
8 | phpcs:
9 | runs-on: ubuntu-latest
10 | timeout-minutes: 5
11 | steps:
12 | - uses: actions/checkout@v4
13 | - uses: shivammathur/setup-php@v2
14 | with:
15 | php-version: 8.1
16 | - run: composer install --no-interaction --no-scripts
17 | - run: vendor/bin/pint --test
18 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to `php-open-graph` will be documented in this file
4 |
5 | ## 0.5.2 - 2021-01-04
6 |
7 | - Add PHP 8.0 support
8 |
9 | ## 0.5.1 - 2020-12-14
10 |
11 | - Fix properties with double quotes in it
12 |
13 | ## 0.5.0 - 2020-09-15
14 |
15 | - Allow to suppress URL suffix for structured properties - [#11](https://github.com/Astrotomic/php-open-graph/pull/11)
16 |
17 | ## 0.4.0 - 2020-08-06
18 |
19 | - Backport to PHP 7.1 - [#9](https://github.com/Astrotomic/php-open-graph/pull/9)
20 |
21 | ## 0.3.0 - 2020-06-14
22 |
23 | - use `og:xxx` instead of `og:xxx:url` if simple string is passed (`image`, `video`, `audio`) - [#5](https://github.com/Astrotomic/php-open-graph/pull/5)
24 |
25 | ## 0.2.4 - 2020-06-11
26 |
27 | - integrate `astrotomic/php-conditional-proxy` to call methods conditionally
28 |
29 | ## 0.2.3 - 2020-06-10
30 |
31 | - add `\Astrotomic\OpenGraph\ConditionalProxy` to allow calling `when()` without callback
32 |
33 | ## 0.2.2 - 2020-06-09
34 |
35 | - fix `\Astrotomic\OpenGraph\StructuredProperties\Audio` prefix
36 | - fix `\Astrotomic\OpenGraph\StructuredProperties\Video` prefix
37 | - add missing `\Astrotomic\OpenGraph\Types\Twitter\SummaryLargeImage::creator()`
38 | - accept stringable objects as image/video/audio
39 |
40 | ## 0.2.1 - 2020-06-09
41 |
42 | - fix "Argument 1 passed to when() must be of the type bool, null given" exception
43 |
44 | ## 0.2.0 - 2020-06-07
45 |
46 | - add Twitter Cards
47 |
48 | ## 0.1.0 - 2020-06-07
49 |
50 | - initial release
51 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Astrotomic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PHP Open-Graph
2 |
3 | [](https://packagist.org/packages/astrotomic/php-open-graph)
4 | [](https://github.com/Astrotomic/php-open-graph/blob/master/LICENSE)
5 | [](https://plant.treeware.earth/Astrotomic/php-open-graph)
6 | [](https://www.larabelles.com/)
7 |
8 | [](https://github.com/Astrotomic/php-open-graph/actions?query=workflow%3Apest)
9 | [](https://github.com/Astrotomic/php-open-graph/actions?query=workflow%3Apint)
10 | [](https://packagist.org/packages/astrotomic/php-open-graph)
11 |
12 | This package provides a fluent PHP OOP builder for [Open Graph protocol](https://ogp.me) and [Twitter Cards](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards).
13 |
14 | ## Installation
15 |
16 | You can install the package via composer:
17 |
18 | ```bash
19 | composer require astrotomic/php-open-graph
20 | ```
21 |
22 | ## Usage
23 |
24 | ```php
25 | use Astrotomic\OpenGraph\OpenGraph;
26 | use Astrotomic\OpenGraph\StructuredProperties\Image;
27 |
28 | echo OpenGraph::website('Example')
29 | ->url('https://example.com')
30 | ->image('https://example.com/image1.jpg')
31 | ->image(Image::make('https://example.com/image2.jpg')->width(600));
32 | ```
33 |
34 | ```html
35 |
36 |
37 |
38 |
39 |
40 |
41 | ```
42 |
43 | ### Types
44 |
45 | #### Global
46 |
47 | - `\Astrotomic\OpenGraph\Types\Article`
48 | - `\Astrotomic\OpenGraph\Types\Book`
49 | - `\Astrotomic\OpenGraph\Types\Profile`
50 | - `\Astrotomic\OpenGraph\Types\Website`
51 |
52 | #### Music
53 |
54 | - `\Astrotomic\OpenGraph\Types\Music\Album`
55 | - `\Astrotomic\OpenGraph\Types\Music\Playlist`
56 | - `\Astrotomic\OpenGraph\Types\Music\RadioStation`
57 | - `\Astrotomic\OpenGraph\Types\Music\Song`
58 |
59 | #### Video
60 |
61 | - `\Astrotomic\OpenGraph\Types\Video\Episode`
62 | - `\Astrotomic\OpenGraph\Types\Video\Movie`
63 | - `\Astrotomic\OpenGraph\Types\Video\Other`
64 | - `\Astrotomic\OpenGraph\Types\Video\TvShow`
65 |
66 | #### Twitter
67 |
68 | - `\Astrotomic\OpenGraph\Types\Twitter\App`
69 | - `\Astrotomic\OpenGraph\Types\Twitter\Player`
70 | - `\Astrotomic\OpenGraph\Types\Twitter\SummaryLargeImage`
71 | - `\Astrotomic\OpenGraph\Types\Twitter\Summary`
72 |
73 | ### Structured Properties
74 |
75 | - `\Astrotomic\OpenGraph\StructuredProperties\Audio`
76 | - `\Astrotomic\OpenGraph\StructuredProperties\Image`
77 | - `\Astrotomic\OpenGraph\StructuredProperties\Video`
78 |
79 | ## Testing
80 |
81 | ```bash
82 | composer test
83 | ```
84 |
85 | ## Changelog
86 |
87 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
88 |
89 | ## Contributing
90 |
91 | Please see [CONTRIBUTING](https://github.com/Astrotomic/.github/blob/master/CONTRIBUTING.md) for details. You could also be interested in [CODE OF CONDUCT](https://github.com/Astrotomic/.github/blob/master/CODE_OF_CONDUCT.md).
92 |
93 | ### Security
94 |
95 | If you discover any security related issues, please check [SECURITY](https://github.com/Astrotomic/.github/blob/master/SECURITY.md) for steps to report it.
96 |
97 | ## Credits
98 |
99 | - [Tom Witkowski](https://github.com/Gummibeer)
100 | - [Alex Vanderbist](https://github.com/AlexVanderbist)
101 | - [All Contributors](../../contributors)
102 |
103 | ## License
104 |
105 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
106 |
107 | ## Treeware
108 |
109 | You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree.
110 |
111 | It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.
112 |
113 | You can buy trees at [offset.earth/treeware](https://plant.treeware.earth/Astrotomic/php-open-graph)
114 |
115 | Read more about Treeware at [treeware.earth](https://treeware.earth)
116 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "astrotomic/php-open-graph",
3 | "description": "Easily generate Open Graph tags",
4 | "license": "MIT",
5 | "keywords": [
6 | "open-graph"
7 | ],
8 | "authors": [
9 | {
10 | "name": "Tom Witkowski",
11 | "email": "gummibeer@astrotomic.info",
12 | "homepage": "https://astrotomic.info",
13 | "role": "Developer"
14 | }
15 | ],
16 | "homepage": "https://github.com/Astrotomic/php-open-graph",
17 | "require": {
18 | "php": "^8.1",
19 | "astrotomic/php-conditional-proxy": "^0.2.1"
20 | },
21 | "require-dev": {
22 | "laravel/pint": "^1.13",
23 | "pestphp/pest": "^2.21",
24 | "spatie/pest-plugin-snapshots": "^2.1"
25 | },
26 | "minimum-stability": "dev",
27 | "prefer-stable": true,
28 | "autoload": {
29 | "psr-4": {
30 | "Astrotomic\\OpenGraph\\": "src"
31 | }
32 | },
33 | "config": {
34 | "allow-plugins": {
35 | "pestphp/pest-plugin": true
36 | },
37 | "sort-packages": true
38 | },
39 | "scripts": {
40 | "fix": "@php vendor/bin/pint",
41 | "test": "@php vendor/bin/pest"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/BaseObject.php:
--------------------------------------------------------------------------------
1 | tags[$prefix.':'.$property] = Property::make($prefix, $property, $content);
17 | }
18 |
19 | public function addProperty(string $prefix, string $property, string $content)
20 | {
21 | $this->tags[] = Property::make($prefix, $property, $content);
22 | }
23 |
24 | public function __toString(): string
25 | {
26 | return implode(PHP_EOL, array_map('strval', $this->tags));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/OpenGraph.php:
--------------------------------------------------------------------------------
1 | prefix = $prefix;
19 | $this->property = $property;
20 | $this->content = $content;
21 | }
22 |
23 | public static function make(string $prefix, string $property, string $content)
24 | {
25 | return new static($prefix, $property, $content);
26 | }
27 |
28 | public function __toString(): string
29 | {
30 | $content = str_replace('"', '"', $this->content);
31 |
32 | return "prefix}:{$this->property}\" content=\"{$content}\">";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/StructuredProperties/Audio.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'secure_url', $url);
12 |
13 | return $this;
14 | }
15 |
16 | public function mimeType(string $mimeType)
17 | {
18 | $this->setProperty(self::PREFIX, 'type', $mimeType);
19 |
20 | return $this;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/StructuredProperties/Image.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'secure_url', $url);
12 |
13 | return $this;
14 | }
15 |
16 | public function mimeType(string $mimeType)
17 | {
18 | $this->setProperty(self::PREFIX, 'type', $mimeType);
19 |
20 | return $this;
21 | }
22 |
23 | public function width(int $width)
24 | {
25 | $this->setProperty(self::PREFIX, 'width', $width);
26 |
27 | return $this;
28 | }
29 |
30 | public function height(int $height)
31 | {
32 | $this->setProperty(self::PREFIX, 'height', $height);
33 |
34 | return $this;
35 | }
36 |
37 | public function alt(string $alt)
38 | {
39 | $this->setProperty(self::PREFIX, 'alt', $alt);
40 |
41 | return $this;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/StructuredProperties/StructuredProperty.php:
--------------------------------------------------------------------------------
1 | setProperty(static::PREFIX, 'url', $url);
13 | } else {
14 | $prefix = explode(':', static::PREFIX, 2);
15 | $this->setProperty($prefix[0], $prefix[1], $url);
16 | }
17 | }
18 |
19 | public static function make(string $url, bool $withUrlSuffix = true)
20 | {
21 | return new static($url, $withUrlSuffix);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/StructuredProperties/Video.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'secure_url', $url);
12 |
13 | return $this;
14 | }
15 |
16 | public function mimeType(string $mimeType)
17 | {
18 | $this->setProperty(self::PREFIX, 'type', $mimeType);
19 |
20 | return $this;
21 | }
22 |
23 | public function width(int $width)
24 | {
25 | $this->setProperty(self::PREFIX, 'width', $width);
26 |
27 | return $this;
28 | }
29 |
30 | public function height(int $height)
31 | {
32 | $this->setProperty(self::PREFIX, 'height', $height);
33 |
34 | return $this;
35 | }
36 |
37 | public function alt(string $alt)
38 | {
39 | $this->setProperty(self::PREFIX, 'alt', $alt);
40 |
41 | return $this;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Twitter.php:
--------------------------------------------------------------------------------
1 | content);
13 |
14 | return "prefix}:{$this->property}\" content=\"{$content}\">";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/TwitterType.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'card', $this->type);
12 | $this->when($title)->title($title);
13 | }
14 |
15 | public static function make(string $title = null)
16 | {
17 | return new static($title);
18 | }
19 |
20 | public function title(string $title)
21 | {
22 | $this->setProperty(self::PREFIX, 'title', $title);
23 |
24 | return $this;
25 | }
26 |
27 | public function site(string $site)
28 | {
29 | $this->setProperty(self::PREFIX, 'site', $site);
30 |
31 | return $this;
32 | }
33 |
34 | public function description(string $description)
35 | {
36 | $this->setProperty(self::PREFIX, 'description', $description);
37 |
38 | return $this;
39 | }
40 |
41 | public function image(string $image, string $alt = null)
42 | {
43 | $this->setProperty(self::PREFIX, 'image', $image);
44 | $this->when($alt)->setProperty(self::PREFIX, 'image:alt', $alt);
45 |
46 | return $this;
47 | }
48 |
49 | public function setProperty(string $prefix, string $property, string $content)
50 | {
51 | $this->tags[$prefix.':'.$property] = TwitterProperty::make($prefix, $property, $content);
52 | }
53 |
54 | public function addProperty(string $prefix, string $property, string $content)
55 | {
56 | $this->tags[] = TwitterProperty::make($prefix, $property, $content);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Type.php:
--------------------------------------------------------------------------------
1 | setProperty('og', 'type', $this->type);
17 | $this->when($title)->title($title);
18 | }
19 |
20 | public static function make(string $title = null)
21 | {
22 | return new static($title);
23 | }
24 |
25 | public function title(string $title)
26 | {
27 | $this->setProperty('og', 'title', $title);
28 |
29 | return $this;
30 | }
31 |
32 | public function url(string $url)
33 | {
34 | $this->setProperty('og', 'url', $url);
35 |
36 | return $this;
37 | }
38 |
39 | public function description(string $description)
40 | {
41 | $this->setProperty('og', 'description', $description);
42 |
43 | return $this;
44 | }
45 |
46 | public function determiner(string $determiner)
47 | {
48 | $this->setProperty('og', 'determiner', $determiner);
49 |
50 | return $this;
51 | }
52 |
53 | public function locale(string $locale)
54 | {
55 | $this->setProperty('og', 'locale', $locale);
56 |
57 | return $this;
58 | }
59 |
60 | public function siteName(string $locale)
61 | {
62 | $this->setProperty('og', 'site_name', $locale);
63 |
64 | return $this;
65 | }
66 |
67 | public function alternateLocale(string $locale)
68 | {
69 | $this->addProperty('og', 'locale:alternate', $locale);
70 |
71 | return $this;
72 | }
73 |
74 | /**
75 | * @param Image|string $image
76 | * @return $this
77 | */
78 | public function image($image)
79 | {
80 | if ($image instanceof Image) {
81 | $this->addStructuredProperty($image);
82 |
83 | return $this;
84 | }
85 |
86 | $this->addProperty('og', 'image', $image);
87 |
88 | return $this;
89 | }
90 |
91 | /**
92 | * @param Video|string $video
93 | * @return $this
94 | */
95 | public function video($video)
96 | {
97 | if ($video instanceof Video) {
98 | $this->addStructuredProperty($video);
99 |
100 | return $this;
101 | }
102 |
103 | $this->addProperty('og', 'video', $video);
104 |
105 | return $this;
106 | }
107 |
108 | /**
109 | * @param Audio|string $audio
110 | * @return $this
111 | */
112 | public function audio($audio)
113 | {
114 | if ($audio instanceof Audio) {
115 | $this->addStructuredProperty($audio);
116 |
117 | return $this;
118 | }
119 |
120 | $this->addProperty('og', 'audio', $audio);
121 |
122 | return $this;
123 | }
124 |
125 | public function addStructuredProperty(BaseObject $property)
126 | {
127 | $this->tags[] = $property;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/Types/Article.php:
--------------------------------------------------------------------------------
1 | addProperty(self::PREFIX, 'author', $url);
18 |
19 | return $this;
20 | }
21 |
22 | public function section(string $section)
23 | {
24 | $this->setProperty(self::PREFIX, 'section', $section);
25 |
26 | return $this;
27 | }
28 |
29 | public function tag(string $tag)
30 | {
31 | $this->addProperty(self::PREFIX, 'tag', $tag);
32 |
33 | return $this;
34 | }
35 |
36 | public function publishedAt(DateTime $releasedAt)
37 | {
38 | $this->setProperty(self::PREFIX, 'published_time', $releasedAt->format(DateTime::ISO8601));
39 |
40 | return $this;
41 | }
42 |
43 | public function modifiedAt(DateTime $modifiedAt)
44 | {
45 | $this->setProperty(self::PREFIX, 'modified_time', $modifiedAt->format(DateTime::ISO8601));
46 |
47 | return $this;
48 | }
49 |
50 | public function expiresAt(DateTime $eexpiresAt)
51 | {
52 | $this->setProperty(self::PREFIX, 'expiration_time', $eexpiresAt->format(DateTime::ISO8601));
53 |
54 | return $this;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Types/Book.php:
--------------------------------------------------------------------------------
1 | addProperty(self::PREFIX, 'author', $url);
18 |
19 | return $this;
20 | }
21 |
22 | public function isbn(string $isbn)
23 | {
24 | $this->setProperty(self::PREFIX, 'isbn', $isbn);
25 |
26 | return $this;
27 | }
28 |
29 | public function releasedAt(DateTime $releaseDate)
30 | {
31 | $this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
32 |
33 | return $this;
34 | }
35 |
36 | public function tag(string $tag)
37 | {
38 | $this->addProperty(self::PREFIX, 'tag', $tag);
39 |
40 | return $this;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Types/Music/Album.php:
--------------------------------------------------------------------------------
1 | addProperty(self::PREFIX, 'musician', $url);
18 |
19 | return $this;
20 | }
21 |
22 | public function song(string $url, int $disc = null, int $track = null)
23 | {
24 | $this->addProperty(self::PREFIX, 'song', $url);
25 | $this->when($disc > 0)->addProperty(self::PREFIX, 'song:disc', $disc);
26 | $this->when($track > 0)->addProperty(self::PREFIX, 'song:track', $track);
27 |
28 | return $this;
29 | }
30 |
31 | public function releasedAt(DateTime $releaseDate)
32 | {
33 | $this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
34 |
35 | return $this;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Types/Music/Playlist.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'creator', $url);
17 |
18 | return $this;
19 | }
20 |
21 | public function song(string $url, int $disc = null, int $track = null)
22 | {
23 | $this->addProperty(self::PREFIX, 'song', $url);
24 | $this->when($disc > 0)->addProperty(self::PREFIX, 'song:disc', $disc);
25 | $this->when($track > 0)->addProperty(self::PREFIX, 'song:track', $track);
26 |
27 | return $this;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Types/Music/RadioStation.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'creator', $url);
17 |
18 | return $this;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Types/Music/Song.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'duration', $seconds);
17 |
18 | return $this;
19 | }
20 |
21 | public function musician(string $url)
22 | {
23 | $this->addProperty(self::PREFIX, 'musician', $url);
24 |
25 | return $this;
26 | }
27 |
28 | public function album(string $url, int $disc = null, int $track = null)
29 | {
30 | $this->addProperty(self::PREFIX, 'album', $url);
31 | $this->when($disc > 0)->addProperty(self::PREFIX, 'album:disc', $disc);
32 | $this->when($track > 0)->addProperty(self::PREFIX, 'album:track', $track);
33 |
34 | return $this;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Types/Profile.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'first_name', $firstName);
17 |
18 | return $this;
19 | }
20 |
21 | public function lastName(string $lastName)
22 | {
23 | $this->setProperty(self::PREFIX, 'last_name', $lastName);
24 |
25 | return $this;
26 | }
27 |
28 | public function username(string $username)
29 | {
30 | $this->setProperty(self::PREFIX, 'username', $username);
31 |
32 | return $this;
33 | }
34 |
35 | public function gender(string $gender)
36 | {
37 | $this->setProperty(self::PREFIX, 'gender', $gender);
38 |
39 | return $this;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Types/Twitter/App.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'app:name:iphone', $name);
15 | $this->setProperty(self::PREFIX, 'app:id:iphone', $iPhoneAppId);
16 | if (! empty($iPhoneAppUrl)) {
17 | $this->setProperty(self::PREFIX, 'app:url:iphone', $iPhoneAppUrl);
18 | }
19 |
20 | return $this;
21 | }
22 |
23 | public function iPadApp(string $name, string $iPadAppId, string $iPadAppUrl = null)
24 | {
25 | $this->setProperty(self::PREFIX, 'app:name:ipad', $name);
26 | $this->setProperty(self::PREFIX, 'app:id:ipad', $iPadAppId);
27 | if (! empty($iPadAppUrl)) {
28 | $this->setProperty(self::PREFIX, 'app:url:ipad', $iPadAppUrl);
29 | }
30 |
31 | return $this;
32 | }
33 |
34 | public function googlePlayApp(string $name, string $googlePlayAppId, string $googlePlayAppUrl = null)
35 | {
36 | $this->setProperty(self::PREFIX, 'app:name:googleplay', $name);
37 | $this->setProperty(self::PREFIX, 'app:id:googleplay', $googlePlayAppId);
38 | if (! empty($googlePlayAppUrl)) {
39 | $this->setProperty(self::PREFIX, 'app:url:googleplay', $googlePlayAppUrl);
40 | }
41 |
42 | return $this;
43 | }
44 |
45 | public function country(string $county = null)
46 | {
47 | if (! empty($county)) {
48 | $county = strtoupper($county);
49 | $this->setProperty(self::PREFIX, 'app:country', $county);
50 | }
51 |
52 | return $this;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Types/Twitter/Player.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'player', $url);
15 | $this->setProperty(self::PREFIX, 'player:width', $width);
16 | $this->setProperty(self::PREFIX, 'player:height', $height);
17 |
18 | return $this;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Types/Twitter/Summary.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'creator', $creator);
15 |
16 | return $this;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Types/Video/Episode.php:
--------------------------------------------------------------------------------
1 | setProperty(self::PREFIX, 'series', $url);
18 |
19 | return $this;
20 | }
21 |
22 | public function actor(string $url, string $role = null)
23 | {
24 | $this->addProperty(self::PREFIX, 'actor', $url);
25 | $this->when($role)->addProperty(self::PREFIX, 'actor:role', $role);
26 |
27 | return $this;
28 | }
29 |
30 | public function director(string $url)
31 | {
32 | $this->addProperty(self::PREFIX, 'director', $url);
33 |
34 | return $this;
35 | }
36 |
37 | public function writer(string $url)
38 | {
39 | $this->addProperty(self::PREFIX, 'writer', $url);
40 |
41 | return $this;
42 | }
43 |
44 | public function duration(int $seconds)
45 | {
46 | $this->setProperty(self::PREFIX, 'duration', $seconds);
47 |
48 | return $this;
49 | }
50 |
51 | public function releasedAt(DateTime $releaseDate)
52 | {
53 | $this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
54 |
55 | return $this;
56 | }
57 |
58 | public function tag(string $tag)
59 | {
60 | $this->addProperty(self::PREFIX, 'tag', $tag);
61 |
62 | return $this;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/Types/Video/Movie.php:
--------------------------------------------------------------------------------
1 | addProperty(self::PREFIX, 'actor', $url);
18 | $this->when($role)->addProperty(self::PREFIX, 'actor:role', $role);
19 |
20 | return $this;
21 | }
22 |
23 | public function director(string $url)
24 | {
25 | $this->addProperty(self::PREFIX, 'director', $url);
26 |
27 | return $this;
28 | }
29 |
30 | public function writer(string $url)
31 | {
32 | $this->addProperty(self::PREFIX, 'writer', $url);
33 |
34 | return $this;
35 | }
36 |
37 | public function duration(int $seconds)
38 | {
39 | $this->setProperty(self::PREFIX, 'duration', $seconds);
40 |
41 | return $this;
42 | }
43 |
44 | public function releasedAt(DateTime $releaseDate)
45 | {
46 | $this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
47 |
48 | return $this;
49 | }
50 |
51 | public function tag(string $tag)
52 | {
53 | $this->addProperty(self::PREFIX, 'tag', $tag);
54 |
55 | return $this;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Types/Video/Other.php:
--------------------------------------------------------------------------------
1 | addProperty(self::PREFIX, 'actor', $url);
18 | $this->when($role)->addProperty(self::PREFIX, 'actor:role', $role);
19 |
20 | return $this;
21 | }
22 |
23 | public function director(string $url)
24 | {
25 | $this->addProperty(self::PREFIX, 'director', $url);
26 |
27 | return $this;
28 | }
29 |
30 | public function writer(string $url)
31 | {
32 | $this->addProperty(self::PREFIX, 'writer', $url);
33 |
34 | return $this;
35 | }
36 |
37 | public function duration(int $seconds)
38 | {
39 | $this->setProperty(self::PREFIX, 'duration', $seconds);
40 |
41 | return $this;
42 | }
43 |
44 | public function releasedAt(DateTime $releaseDate)
45 | {
46 | $this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
47 |
48 | return $this;
49 | }
50 |
51 | public function tag(string $tag)
52 | {
53 | $this->addProperty(self::PREFIX, 'tag', $tag);
54 |
55 | return $this;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Types/Video/TvShow.php:
--------------------------------------------------------------------------------
1 | addProperty(self::PREFIX, 'actor', $url);
18 | $this->when($role)->addProperty(self::PREFIX, 'actor:role', $role);
19 |
20 | return $this;
21 | }
22 |
23 | public function director(string $url)
24 | {
25 | $this->addProperty(self::PREFIX, 'director', $url);
26 |
27 | return $this;
28 | }
29 |
30 | public function writer(string $url)
31 | {
32 | $this->addProperty(self::PREFIX, 'writer', $url);
33 |
34 | return $this;
35 | }
36 |
37 | public function releasedAt(DateTime $releaseDate)
38 | {
39 | $this->setProperty(self::PREFIX, 'release_date', $releaseDate->format('Y-m-d'));
40 |
41 | return $this;
42 | }
43 |
44 | public function tag(string $tag)
45 | {
46 | $this->addProperty(self::PREFIX, 'tag', $tag);
47 |
48 | return $this;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Types/Website.php:
--------------------------------------------------------------------------------
1 |