Completed
Push — master ( edcf20...3ec6c0 )
by Marcel
03:05 queued 01:22
created

src/Statistics/Events/StatisticsUpdated.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\Statistics\Events;
4
5
use Illuminate\Queue\SerializesModels;
6
use Illuminate\Broadcasting\PrivateChannel;
7
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
8
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
9
use BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry;
10
11
class StatisticsUpdated implements ShouldBroadcast
12
{
13
    use SerializesModels;
14
15
    /** @var \BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry */
16
    protected $webSocketsStatisticsEntry;
17
18
    public function __construct(WebSocketsStatisticsEntry $webSocketsStatisticsEntry)
19
    {
20
        $this->webSocketsStatisticsEntry = $webSocketsStatisticsEntry;
21
    }
22
23
    public function broadcastWith()
24
    {
25
        return [
26
            'time' => (string) $this->webSocketsStatisticsEntry->created_at,
0 ignored issues
show
The property created_at does not exist on object<BeyondCode\Larave...SocketsStatisticsEntry>. 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...
27
            'app_id' => $this->webSocketsStatisticsEntry->app_id,
0 ignored issues
show
The property app_id does not exist on object<BeyondCode\Larave...SocketsStatisticsEntry>. 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...
28
            'peak_connection_count' => $this->webSocketsStatisticsEntry->peak_connection_count,
29
            'websocket_message_count' => $this->webSocketsStatisticsEntry->websocket_message_count,
0 ignored issues
show
The property websocket_message_count does not exist on object<BeyondCode\Larave...SocketsStatisticsEntry>. 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...
30
            'api_message_count' => $this->webSocketsStatisticsEntry->api_message_count,
0 ignored issues
show
The property api_message_count does not exist on object<BeyondCode\Larave...SocketsStatisticsEntry>. 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...
31
        ];
32
    }
33
34
    public function broadcastOn()
35
    {
36
        $channelName = str_after(DashboardLogger::LOG_CHANNEL_PREFIX.'statistics', 'private-');
37
38
        return new PrivateChannel($channelName);
39
    }
40
41
    public function broadcastAs()
42
    {
43
        return 'statistics-updated';
44
    }
45
}
46