Skip to content

Commit 78a44e0

Browse files
committed
Update
1 parent 4ea698b commit 78a44e0

File tree

4 files changed

+65
-71
lines changed

4 files changed

+65
-71
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"minimum-stability": "stable",
77
"autoload": {
88
"psr-4": {
9-
"Json2video\\json2video-php-sdk\\": "src/"
9+
"JSON2Video\\": "src/"
1010
}
1111
},
1212
"require": {

src/Base.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace JSON2Video;
4+
5+
class Base {
6+
7+
protected $object, $properties;
8+
9+
public function __get($property) {
10+
$property = strtolower($property);
11+
if (in_array($property, $this->properties) && isset($this->object[$property])) {
12+
return $this->object[$property];
13+
}
14+
15+
return null;
16+
}
17+
18+
public function __set($property, $value) {
19+
$property = strtolower($property);
20+
if (in_array($property, $this->properties)) {
21+
$property = strtolower(str_replace('_', '-', $property));
22+
$this->object[$property] = $value;
23+
return $value;
24+
}
25+
26+
return null;
27+
}
28+
29+
public function addElement($element=null) {
30+
if ($element && is_array($element)) {
31+
if (!isset($this->object['elements'])) $this->object['elements'] = [];
32+
$this->object['elements'][] = $element;
33+
return true;
34+
}
35+
return false;
36+
}
37+
38+
public function getJSON() {
39+
return json_encode($this->object, JSON_PRETTY_PRINT);
40+
}
41+
42+
public function getObject() {
43+
return $this->object;
44+
}
45+
}

src/json2video-php-sdk.php renamed to src/Movie.php

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,7 @@
11
<?php
22

3-
/*
4-
5-
JSON2Video PHP SDK
6-
7-
This simple SDK is a wrapper for calling JSON2Video API
8-
JSON2Video API allows you to create and edit videos programmatically
9-
10-
Documentation: https://json2video.com/docs/sdk
11-
12-
*/
13-
143
namespace JSON2Video;
154

16-
class Base {
17-
18-
protected $object, $properties;
19-
20-
public function __get($property) {
21-
$property = strtolower($property);
22-
if (in_array($property, $this->properties) && isset($this->object[$property])) {
23-
return $this->object[$property];
24-
}
25-
26-
return null;
27-
}
28-
29-
public function __set($property, $value) {
30-
$property = strtolower($property);
31-
if (in_array($property, $this->properties)) {
32-
$property = strtolower(str_replace('_', '-', $property));
33-
$this->object[$property] = $value;
34-
return $value;
35-
}
36-
37-
return null;
38-
}
39-
40-
public function addElement($element=null) {
41-
if ($element && is_array($element)) {
42-
if (!isset($this->object['elements'])) $this->object['elements'] = [];
43-
$this->object['elements'][] = $element;
44-
return true;
45-
}
46-
return false;
47-
}
48-
49-
public function getJSON() {
50-
return json_encode($this->object, JSON_PRETTY_PRINT);
51-
}
52-
53-
public function getObject() {
54-
return $this->object;
55-
}
56-
}
57-
58-
59-
class Scene extends Base {
60-
protected $properties = ['comment', 'background_color', 'duration', 'cache'];
61-
62-
protected $object = [];
63-
64-
public function setTransition($style=null, $duration=null, $type=null) {
65-
if ($style || $duration || $type) {
66-
if (!isset($this->object['transition'])) $this->object['transition'] = [];
67-
if (!is_null($style)) $this->object['transition']['style'] = $style;
68-
if (!is_null($duration)) $this->object['transition']['duration'] = $duration;
69-
if (!is_null($type)) $this->object['transition']['type'] = $type;
70-
}
71-
}
72-
73-
}
74-
755
class Movie extends Base {
766
private $api_url = 'https://api.json2video.com/v1/movies';
777
protected $properties = ['comment', 'project', 'width', 'height', 'resolution', 'quality', 'fps', 'cache'];

src/Scene.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace JSON2Video;
4+
5+
class Scene extends Base {
6+
protected $properties = ['comment', 'background_color', 'duration', 'cache'];
7+
8+
protected $object = [];
9+
10+
public function setTransition($style=null, $duration=null, $type=null) {
11+
if ($style || $duration || $type) {
12+
if (!isset($this->object['transition'])) $this->object['transition'] = [];
13+
if (!is_null($style)) $this->object['transition']['style'] = $style;
14+
if (!is_null($duration)) $this->object['transition']['duration'] = $duration;
15+
if (!is_null($type)) $this->object['transition']['type'] = $type;
16+
}
17+
}
18+
19+
}

0 commit comments

Comments
 (0)