Issues (45)

src/models/Tweet.php (3 issues)

1
<?php
2
/**
3
 * @link      https://dukt.net/twitter/
4
 * @copyright Copyright (c) Dukt
5
 * @license   https://github.com/dukt/twitter/blob/master/LICENSE.md
6
 */
7
8
namespace dukt\twitter\models;
9
10
use craft\base\Model;
11
use craft\errors\ImageException;
12
use dukt\twitter\helpers\TwitterHelper;
13
use GuzzleHttp\Exception\GuzzleException;
14
15
/**
16
 * Tweet model class.
17
 *
18
 * @author Dukt <[email protected]>
19
 * @since  3.0
20
 */
21
class Tweet extends Model
22
{
23
    // Properties
24
    // =========================================================================
25
26
    /**
27
     * @var The date the tweet was created at.
0 ignored issues
show
The type dukt\twitter\models\The was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
     */
29
    public $createdAt;
30
31
    /**
32
     * @var Raw tweet data.
0 ignored issues
show
The type dukt\twitter\models\Raw was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
     */
34
    public $data;
35
36
    /**
37
     * @var The tweet’s text.
38
     */
39
    public $text;
40
41
    /**
42
     * @var The tweet’s ID.
43
     */
44
    public $remoteId;
45
46
    /**
47
     * @var The tweet’s author user ID.
48
     */
49
    public $remoteUserId;
50
51
    /**
52
     * @var The author user’s username.
53
     */
54
    public $username;
55
56
    /**
57
     * @var The author user’s profile remote image secure URL.
58
     */
59
    public $userProfileRemoteImageSecureUrl;
60
61
    /**
62
     * @var The author user’s profile remote image URL.
63
     */
64
    public $userProfileRemoteImageUrl;
65
66
    /**
67
     * @var The author user’s screen name.
68
     */
69
    public $userScreenName;
70
71
    // Public Methods
72
    // =========================================================================
73
74
    /**
75
     * Returns the URL of the tweet.
76
     *
77
     * @return string|null
78
     */
79
    public function getUrl()
80
    {
81
        if (!$this->remoteId || !$this->userScreenName) {
82
            return null;
83
        }
84
85
        return 'https://twitter.com/'.$this->userScreenName.'/status/'.$this->remoteId;
86
    }
87
88
    /**
89
     * Returns the tweet's author user profile image resource url.
90
     *
91
     * @param int $size
92
     *
93
     * @return null|string
94
     * @throws GuzzleException
95
     * @throws ImageException
96
     * @throws \yii\base\Exception
97
     */
98
    public function getUserProfileImageUrl($size = 48)
99
    {
100
        return TwitterHelper::getUserProfileImageResourceUrl($this->remoteUserId, $size);
0 ignored issues
show
$this->remoteUserId of type dukt\twitter\models\The is incompatible with the type integer expected by parameter $remoteUserId of dukt\twitter\helpers\Twi...ofileImageResourceUrl(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

100
        return TwitterHelper::getUserProfileImageResourceUrl(/** @scrutinizer ignore-type */ $this->remoteUserId, $size);
Loading history...
101
    }
102
103
    /**
104
     * Returns the tweet's author user profile URL.
105
     *
106
     * @return mixed
107
     */
108
    public function getUserProfileUrl()
109
    {
110
        return 'https://twitter.com/'.$this->userScreenName;
111
    }
112
}
113