-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
612 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
<?php | ||
|
||
namespace Bissolli\TwitterScraper\Models; | ||
|
||
class Account extends ModelAbstract | ||
{ | ||
/** | ||
* Name | ||
* @var string | ||
*/ | ||
protected $name = null; | ||
|
||
/** | ||
* Joined on Twitter at | ||
* @var string | ||
*/ | ||
protected $joinedAt = null; | ||
|
||
/** | ||
* Avatar url | ||
* @var string | ||
*/ | ||
protected $avatarUrl = null; | ||
|
||
/** | ||
* Cover url | ||
* @var string | ||
*/ | ||
protected $coverUrl = null; | ||
|
||
/** | ||
* Website url | ||
* @var string | ||
*/ | ||
protected $website = null; | ||
|
||
/** | ||
* Locale | ||
* @var string | ||
*/ | ||
protected $locale = null; | ||
|
||
/** | ||
* Bio filled by the user | ||
* @var string | ||
*/ | ||
protected $bio = null; | ||
|
||
/** | ||
* Number of users the user is following | ||
* @var integer | ||
*/ | ||
protected $followingCount = 0; | ||
|
||
/** | ||
* Number of followers | ||
* @var integer | ||
*/ | ||
protected $followersCount = 0; | ||
|
||
/** | ||
* Total number of tweets published by the user | ||
* @var integer | ||
*/ | ||
protected $tweetsCount = 0; | ||
|
||
/** | ||
* Total of favorites | ||
* @var integer | ||
*/ | ||
protected $favoritesCount = 0; | ||
|
||
/** | ||
* Total of lists | ||
* @var integer | ||
*/ | ||
protected $listsCount = 0; | ||
|
||
/** | ||
* Date of birth | ||
* @var integer | ||
*/ | ||
protected $dateOfBirth = null; | ||
|
||
/** | ||
* true if verified by Twitter | ||
* @var boolean | ||
*/ | ||
protected $isVerified = false; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAvatarUrl() | ||
{ | ||
return $this->avatarUrl; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCoverUrl() | ||
{ | ||
return $this->coverUrl; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getWebsite() | ||
{ | ||
return $this->website; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLocale() | ||
{ | ||
return $this->locale; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getBio() | ||
{ | ||
return $this->bio; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getFollowingCount() | ||
{ | ||
return $this->followingCount; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getFollowersCount() | ||
{ | ||
return $this->followersCount; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getTweetsCount() | ||
{ | ||
return $this->tweetsCount; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getListsCount() | ||
{ | ||
return $this->listsCount; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getFavoritesCount() | ||
{ | ||
return $this->favoritesCount; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isVerified() | ||
{ | ||
return $this->isVerified; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getDateOfBirth() | ||
{ | ||
return $this->dateOfBirth; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getJoinedAt() | ||
{ | ||
return $this->joinedAt; | ||
} | ||
|
||
/** | ||
* @param $value | ||
* @param $prop | ||
*/ | ||
public function initProperties($value, $prop) | ||
{ | ||
switch ($prop) { | ||
case 'name': | ||
$this->name = $value; | ||
break; | ||
case 'joined_at': | ||
$this->joinedAt = $value; | ||
break; | ||
case 'avatar_url': | ||
$this->avatarUrl = $value; | ||
break; | ||
case 'cover_url': | ||
$this->coverUrl = $value; | ||
break; | ||
case 'website': | ||
$this->website = $value; | ||
break; | ||
case 'locale': | ||
$this->locale = $value; | ||
break; | ||
case 'bio': | ||
$this->bio = $value; | ||
break; | ||
case 'following_count': | ||
$this->followingCount = $value; | ||
break; | ||
case 'followers_count': | ||
$this->followersCount = $value; | ||
break; | ||
case 'tweets_count': | ||
$this->tweetsCount = $value; | ||
break; | ||
case 'favorites_count': | ||
$this->favoritesCount = $value; | ||
break; | ||
case 'lists_count': | ||
$this->listsCount = $value; | ||
break; | ||
case 'date_of_birth': | ||
$this->dateOfBirth = $value; | ||
break; | ||
case 'is_verified': | ||
$this->isVerified = (bool) $value; | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Bissolli\TwitterScraper\Models; | ||
|
||
use ArrayAccess; | ||
use Bissolli\TwitterScraper\Traits\ArrayLikeTrait; | ||
|
||
abstract class ModelAbstract implements ArrayAccess, ModelInterface | ||
{ | ||
use ArrayLikeTrait; | ||
|
||
/** | ||
* @param array $props | ||
*/ | ||
protected function __construct(array $props = null) | ||
{ | ||
$this->init($props); | ||
} | ||
|
||
/** | ||
* @param array $props | ||
* | ||
* @return $this | ||
*/ | ||
final protected function init(array $props) | ||
{ | ||
foreach ($props as $prop => $value) { | ||
$this->initProperties($value, $prop); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected static $initPropertiesMap = []; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public static function getColumns() | ||
{ | ||
return array_keys(static::$initPropertiesMap); | ||
} | ||
|
||
/** | ||
* @param array $params | ||
* | ||
* @return static | ||
*/ | ||
public static function create(array $params = null) | ||
{ | ||
return new static($params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Bissolli\TwitterScraper\Models; | ||
|
||
interface ModelInterface | ||
{ | ||
/** | ||
* @param $value | ||
* @param $prop | ||
*/ | ||
public function initProperties($value, $prop); | ||
} |
Oops, something went wrong.