PiedWeb /
SeoPocketCrawler
| 1 | <?php |
||
| 2 | |||
| 3 | namespace PiedWeb\SeoPocketCrawler; |
||
| 4 | |||
| 5 | use League\Uri\Http; |
||
| 6 | use League\Uri\UriInfo; |
||
| 7 | |||
| 8 | class Url |
||
| 9 | { |
||
| 10 | private static $autoIncrement = 1; |
||
| 11 | |||
| 12 | public $id; |
||
| 13 | public $discovered; |
||
| 14 | public $uri; |
||
| 15 | public $click; |
||
| 16 | public $pagerank; |
||
| 17 | public $inboundlinks; |
||
| 18 | public $inboundlinks_nofollow = 0; |
||
| 19 | public $can_be_crawled; |
||
| 20 | public $indexable; |
||
| 21 | public $mime_type; |
||
| 22 | public $links; |
||
| 23 | public $links_duplicate; |
||
| 24 | public $links_self; |
||
| 25 | public $links_internal; |
||
| 26 | public $links_sub; |
||
| 27 | public $links_external; |
||
| 28 | public $word_count; |
||
| 29 | public $load_time; |
||
| 30 | public $size; |
||
| 31 | public $title; |
||
| 32 | public $updated_at; |
||
| 33 | //public $kws; |
||
| 34 | //public $h1; |
||
| 35 | //public $breadcrumb_level; |
||
| 36 | //public $breadcrumb_first; |
||
| 37 | //public $breadcrumb_text; |
||
| 38 | |||
| 39 | public function __construct($url, $click = null) |
||
| 40 | { |
||
| 41 | $this->id = $this->getId(); |
||
| 42 | $this->uri = substr($url, strlen(UriInfo::getOrigin(Http::createFromString($url)))); //! |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 43 | $this->updated_at = date('Ymd'); |
||
| 44 | $this->inboundlinks = 0; |
||
| 45 | $this->click = $click; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function getId() |
||
| 49 | { |
||
| 50 | if (null === $this->id) { |
||
| 51 | $this->id = self::$autoIncrement; |
||
| 52 | ++self::$autoIncrement; |
||
| 53 | } |
||
| 54 | |||
| 55 | return $this->id; |
||
| 56 | } |
||
| 57 | |||
| 58 | public function setDiscovered(int $discovered) |
||
| 59 | { |
||
| 60 | $this->discovered = $discovered; |
||
| 61 | |||
| 62 | return $this; |
||
| 63 | } |
||
| 64 | |||
| 65 | public function setMimeType(string $mimeType) |
||
| 66 | 9 | { |
|
| 67 | $this->mime_type = 'text/html' == $mimeType ? 1 : $mimeType; |
||
| 68 | 9 | ||
| 69 | 9 | return $this; |
|
| 70 | 9 | } |
|
| 71 | 9 | ||
| 72 | 9 | /** |
|
| 73 | 9 | public function setH1(string $h1) |
|
| 74 | { |
||
| 75 | 9 | $this->h1 = $this->title == $h1 ? '=' : $h1; |
|
| 76 | |||
| 77 | 9 | return $this; |
|
| 78 | 9 | }/**/ |
|
| 79 | 9 | public function setId($id) |
|
| 80 | { |
||
| 81 | $this->id = intval($id); |
||
| 82 | 9 | } |
|
| 83 | |||
| 84 | public function getDiscovered() |
||
| 85 | 9 | { |
|
| 86 | return $this->discovered; |
||
| 87 | 9 | } |
|
| 88 | |||
| 89 | 9 | public function getUri() |
|
| 90 | { |
||
| 91 | return $this->uri; |
||
| 92 | } |
||
| 93 | |||
| 94 | public function setUri($uri) |
||
| 95 | { |
||
| 96 | $this->uri = $uri; |
||
| 97 | } |
||
| 98 | |||
| 99 | public function getClick() |
||
| 100 | { |
||
| 101 | return $this->click; |
||
| 102 | } |
||
| 103 | |||
| 104 | public function setClick($click) |
||
| 105 | { |
||
| 106 | $this->click = (int) $click; |
||
| 107 | } |
||
| 108 | |||
| 109 | public function getPagerank() |
||
| 110 | { |
||
| 111 | return $this->pagerank; |
||
| 112 | } |
||
| 113 | |||
| 114 | public function setPagerank($pagerank) |
||
| 115 | { |
||
| 116 | $this->pagerank = (float) $pagerank; |
||
| 117 | } |
||
| 118 | |||
| 119 | public function getInboundlinks() |
||
| 120 | { |
||
| 121 | return $this->inboundlinks; |
||
| 122 | } |
||
| 123 | |||
| 124 | public function setInboundlinks($inboundlinks) |
||
| 125 | { |
||
| 126 | $this->inboundlinks = (int) $inboundlinks; |
||
| 127 | } |
||
| 128 | |||
| 129 | public function getInboundlinksNofollow() |
||
| 130 | { |
||
| 131 | return $this->inboundlinks_nofollow; |
||
| 132 | } |
||
| 133 | |||
| 134 | public function setInboundlinksNofollow($inboundlinks_nofollow) |
||
| 135 | { |
||
| 136 | $this->inboundlinks_nofollow = (int) $inboundlinks_nofollow; |
||
| 137 | } |
||
| 138 | |||
| 139 | public function getCanBeCrawled() |
||
| 140 | { |
||
| 141 | return $this->can_be_crawled; |
||
| 142 | } |
||
| 143 | |||
| 144 | public function setCanBeCrawled($can_be_crawled) |
||
| 145 | { |
||
| 146 | $this->can_be_crawled = (bool) $can_be_crawled; |
||
| 147 | } |
||
| 148 | |||
| 149 | public function getIndexable() |
||
| 150 | { |
||
| 151 | return $this->indexable; |
||
| 152 | } |
||
| 153 | |||
| 154 | public function setIndexable($indexable) |
||
| 155 | { |
||
| 156 | $this->indexable = (int) $indexable; |
||
| 157 | } |
||
| 158 | |||
| 159 | public function getMimeType() |
||
| 160 | { |
||
| 161 | return $this->mime_type; |
||
| 162 | } |
||
| 163 | |||
| 164 | public function getLinks() |
||
| 165 | { |
||
| 166 | return $this->links; |
||
| 167 | } |
||
| 168 | |||
| 169 | public function setLinks($links) |
||
| 170 | { |
||
| 171 | $this->links = (int) $links; |
||
| 172 | } |
||
| 173 | |||
| 174 | public function getLinksDuplicate() |
||
| 175 | { |
||
| 176 | return (int) $this->links_duplicate; |
||
| 177 | } |
||
| 178 | |||
| 179 | public function setLinksDuplicate($links_duplicate) |
||
| 180 | { |
||
| 181 | $this->links_duplicate = (int) $links_duplicate; |
||
| 182 | } |
||
| 183 | |||
| 184 | public function getLinksSelf() |
||
| 185 | { |
||
| 186 | return $this->links_self; |
||
| 187 | } |
||
| 188 | |||
| 189 | public function setLinksSelf($links_self) |
||
| 190 | { |
||
| 191 | $this->links_self = (int) $links_self; |
||
| 192 | } |
||
| 193 | |||
| 194 | public function getLinksInternal() |
||
| 195 | { |
||
| 196 | return $this->links_internal; |
||
| 197 | } |
||
| 198 | |||
| 199 | public function setLinksInternal($links_internal) |
||
| 200 | { |
||
| 201 | $this->links_internal = (int) $links_internal; |
||
| 202 | } |
||
| 203 | |||
| 204 | public function getLinksSub() |
||
| 205 | { |
||
| 206 | return $this->links_sub; |
||
| 207 | } |
||
| 208 | |||
| 209 | public function setLinksSub($links_sub) |
||
| 210 | { |
||
| 211 | $this->links_sub = (int) $links_sub; |
||
| 212 | } |
||
| 213 | |||
| 214 | public function getLinksExternal() |
||
| 215 | { |
||
| 216 | return $this->links_external; |
||
| 217 | } |
||
| 218 | |||
| 219 | public function setLinksExternal($links_external) |
||
| 220 | { |
||
| 221 | $this->links_external = (int) $links_external; |
||
| 222 | } |
||
| 223 | |||
| 224 | public function getWordCount() |
||
| 225 | { |
||
| 226 | return $this->word_count; |
||
| 227 | } |
||
| 228 | |||
| 229 | public function setWordCount($word_count) |
||
| 230 | { |
||
| 231 | $this->word_count = (int) $word_count; |
||
| 232 | } |
||
| 233 | |||
| 234 | public function getLoadTime() |
||
| 235 | { |
||
| 236 | return $this->load_time; |
||
| 237 | } |
||
| 238 | |||
| 239 | public function setLoadTime($load_time) |
||
| 240 | { |
||
| 241 | $this->load_time = (int) $load_time; |
||
| 242 | } |
||
| 243 | |||
| 244 | public function getSize() |
||
| 245 | { |
||
| 246 | return $this->size; |
||
| 247 | } |
||
| 248 | |||
| 249 | public function setSize($size) |
||
| 250 | { |
||
| 251 | $this->size = (int) $size; |
||
| 252 | } |
||
| 253 | |||
| 254 | public function getTitle() |
||
| 255 | { |
||
| 256 | return $this->title; |
||
| 257 | } |
||
| 258 | |||
| 259 | public function setTitle($title) |
||
| 260 | { |
||
| 261 | $this->title = $title; |
||
| 262 | } |
||
| 263 | |||
| 264 | public function getUpdatedAt() |
||
| 265 | { |
||
| 266 | return $this->updated_at; |
||
| 267 | } |
||
| 268 | |||
| 269 | public function setUpdatedAt($updated_at) |
||
| 270 | { |
||
| 271 | $this->updated_at = $updated_at; |
||
| 272 | } |
||
| 273 | } |
||
| 274 |