File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed
Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 88
99class DurationCalculator
1010{
11- CONST CHARACTERS_PER_SECOND = 25 ;
12-
1311 public function __construct (
1412 protected Content $ content
1513 ) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Yuges \Contentable \Data \Blocks ;
4+
5+ use Yuges \Contentable \Config \Config ;
6+ use Yuges \Contentable \Enums \BlockType ;
7+ use Yuges \Contentable \Interfaces \BlockType as BlockTypeInterface ;
8+
9+ class ImageData extends \Yuges \Contentable \Abstracts \BlockData
10+ {
11+ protected const BlockTypeInterface TYPE = BlockType::Image;
12+
13+ public function __construct (
14+ public array $ file = [
15+ 'url ' => '' ,
16+ ],
17+ public ?string $ caption = '' ,
18+ public bool $ stretched = true ,
19+ public bool $ withBorder = false ,
20+ public bool $ withBackground = false ,
21+ ) {
22+ parent ::__construct ();
23+ }
24+
25+ public function getData (): array
26+ {
27+ return [
28+ 'file ' => $ this ->file ,
29+ 'caption ' => $ this ->caption ,
30+ 'stretched ' => $ this ->stretched ,
31+ 'withBorder ' => $ this ->withBorder ,
32+ 'withBackground ' => $ this ->withBackground ,
33+ ];
34+ }
35+
36+ public function duration (): float
37+ {
38+ $ calculator = Config::getDurationCalculatorClass ();
39+
40+ return ($ this ->file ['url ' ] ?? 0 ? 5 : 0 ) + $ calculator ::duration ($ this ->caption );
41+ }
42+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ enum BlockType: string implements \Yuges\Contentable\Interfaces\BlockType
66{
77 case List = 'list ' ;
88 case Quote = 'quote ' ;
9+ case Image = 'image ' ;
910 case Header = 'header ' ;
1011 case Paragraph = 'paragraph ' ;
1112 case Delimiter = 'delimiter ' ;
You can’t perform that action at this time.
0 commit comments