`CrawlObserver` and `CrawlProfile` interfaces
rudiedirkx opened this issue · comments
If CrawlObserver
and CrawlProfile
were interfaces, I could have the observer and profile be 1 object. Currently, since my observer and profile HAVE to extend your class, they need a separate object (my custom object) injected into the observer and profile for tracking/progress/state/counting etc. There's nothing wrong with that, but interfaces would be nicer. Generally you want to hint interfaces, not classes, because they can be anything.
What I do now:
class MyProgress {
// my state & some shared crawling logic here
}
class MyObserver extends CrawlObserver {
function __construct(public MyProgress $progress) {}
// observer logic here, that uses $this->progress
}
class MyProfiler extends CrawlProfile {
function __construct(public MyProgress $progress) {}
// profile logic here, that uses $this->progress
}
What I'd like to do:
class MyProgress implements CrawlObserver, CrawlProfile {
// my state here
// and observer logic
// and profile logic
}
You can't break extends CrawlObserver
or extends CrawlProfile
, but you can make a CrawlObserverInterface
and CrawlProfileInterface
and use those internally. Maybe?