Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rationale for Analytics::new() #32

Closed
8ctopus opened this issue Feb 24, 2023 · 2 comments
Closed

rationale for Analytics::new() #32

8ctopus opened this issue Feb 24, 2023 · 2 comments
Labels
question Further information is requested

Comments

@8ctopus
Copy link
Contributor

8ctopus commented Feb 24, 2023

Hi again Alex,

What is the rationale for Analytics::new('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true) instead of new Analytics('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true)?

@aawnu
Copy link
Owner

aawnu commented Feb 24, 2023

Hi again Alex,

What is the rationale for Analytics::new('G-XXXXXX', 'eMVPMEcTbaI1iuWtrPw', true) instead of new 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
Copy link
Contributor Author

8ctopus commented Feb 24, 2023

Oh I see, thank you for the explanation, I mainly use the second option, now I know one more.

@8ctopus 8ctopus closed this as completed Feb 24, 2023
@aawnu aawnu added the question Further information is requested label Feb 24, 2023
Repository owner locked as resolved and limited conversation to collaborators Apr 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants