| 1 | <?php |
||
| 8 | class WebScrapingController extends Controller |
||
| 9 | { |
||
| 10 | protected $crawler; |
||
| 11 | |||
| 12 | const NEWS_URL = 'https://news.ycombinator.com/'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Initialize controller |
||
| 16 | */ |
||
| 17 | public function __construct() |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Return all data to the Stripe API dashboard |
||
| 24 | * @return mixed |
||
| 25 | */ |
||
| 26 | public function getPage() |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Scrape the Links |
||
| 35 | * @param $siteToCrawl |
||
| 36 | * @return array |
||
| 37 | */ |
||
| 38 | public function getData($siteToCrawl) |
||
| 52 | } |
||
| 53 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: