rationale for Analytics::new()
8ctopus opened this issue · 2 comments
8ctopus commented
Hi again Alex,
What is the rationale for Analytics::new('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true)
instead of new Analytics('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true)
?
aawnu commented
Hi again Alex,
What is the rationale for
Analytics::new('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true)
instead ofnew Analytics('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true)
?
Thats mainly a readability thing for quick nested methods
$analytics = new Analytics('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true);
$analytics->method()
->method()
->method();
compared to
$analytics = (new Analytics('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true))
->method()
->method()
->method();
compared to
$analytics = Analytics::new('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true)
->method()
->method()
->method();
8ctopus commented
Oh I see, thank you for the explanation, I mainly use the second option, now I know one more.