Completed
Pull Request — master (#63)
by Marko
03:19
created

Videosphere::autoplay()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 6
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jul 7, 2016 - 4:51:28 AM
5
 * Contact      [email protected]
6
 * @copyright   2016 Marko Kungla - https://github.com/mkungla
7
 * @license     The MIT License (MIT)
8
 * 
9
 * @category       AframeVR
10
 * @package        aframe-php
11
 * 
12
 * Lang         PHP (php version >= 7)
13
 * Encoding     UTF-8
14
 * File         Videosphere.php
15
 * Code format  PSR-2 and 12
16
 * @link        https://github.com/mkungla/aframe-php
17
 * @issues      https://github.com/mkungla/aframe-php/issues
18
 * ********************************************************************
19
 * Contributors:
20
 * @author Marko Kungla <[email protected]>
21
 * ********************************************************************
22
 * Comments:
23
 * @formatter:on */
24
namespace AframeVR\Extras\Primitives;
25
26
use \AframeVR\Core\Entity;
27
use \AframeVR\Interfaces\EntityInterface;
28
29
class Videosphere extends Entity implements EntityInterface
30
{
31
32
    /**
33
     * Init <a-video>
34
     *
35
     * The video primitive displays a video on a flat plane as a texture. It is an entity that prescribes the geometry
36
     * with its geometric primitive set to plane.
37
     *
38
     * @return void
39
     */
40
    public function init()
41
    {
42
        /* Load defaults */
43
        $this->defaults();
44
    }
45
46
    /**
47
     * Set defaults
48
     *
49
     * {@inheritdoc}
50
     *
51
     * @return void
52
     */
53
    public function defaults()
54
    {
55
        $this->component('Material')->shader('flat');
56
        $this->color('#FFF');
57
        
58
        $this->component('Geometry')->primitive('sphere');
59
        $this->component('Geometry')->radius(5000);
60
        $this->component('Geometry')->segmentsWidth(64);
61
        $this->component('Geometry')->segmentsWidth(20);
62
        
63
        $this->scale(- 1, 1, 1);
64
    }
65
66
    /**
67
     * geometry.radius
68
     *
69
     * @param float $radius            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $radius not be integer|double?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
70
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
71
     */
72
    public function radius(float $radius = 100): self
73
    {
74
        $this->component('Geometry')->radius($radius);
75
        return $this;
76
    }
77
78
    /**
79
     * Autoplay video
80
     *
81
     * @param bool $autoplay            
82
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
83
     */
84
    public function autoplay(bool $autoplay = true): self
85
    {
86
        $this->attrs['autoplay'] = $autoplay ? 'true' : 'false';
87
        return $this;
88
    }
89
90
    /**
91
     * geometry.segmentsHeight
92
     *
93
     * @param int $segmentsHeigh            
94
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
95
     */
96
    public function segmentsHeight($segmentsHeigh = 64): self
97
    {
98
        $this->component('Geometry')->segmentsHeight($segmentsHeigh);
99
        return $this;
100
    }
101
102
    /**
103
     * geometry.segmentsWidth
104
     *
105
     * @param int $segmentsWidth            
106
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
107
     */
108
    public function segmentsWidth($segmentsWidth = 64): self
109
    {
110
        $this->component('Geometry')->segmentsWidth($segmentsWidth);
111
        return $this;
112
    }
113
}
114