Completed
Pull Request — master (#6)
by Tyler
09:27
created

ViddlerFinished::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace LeadThread\Viddler\Upload\Events;
4
5
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
6
use Illuminate\Queue\SerializesModels;
7
use LeadThread\Viddler\Upload\Models\Viddler;
8
9 View Code Duplication
class ViddlerFinished implements ShouldBroadcast
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    use SerializesModels;
12
13
    public $model;
14
15
    /**
16
     * Create a new event instance.
17
     *
18
     * @param  Viddler  $model
19
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
     */
21 3
    public function __construct(Viddler $model)
22
    {
23 3
        $this->model = $model;
24 3
    }
25
26
    /**
27
     * Get the channels the event should be broadcast on.
28
     *
29
     * @return string[]
30
     */
31 3
    public function broadcastOn()
32
    {
33 3
        return ['viddler.'.$this->model->id];
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<LeadThread\Viddler\Upload\Models\Viddler>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
34
    }
35
}
36