Mapping to Square is Endomorphism iff Abelian

Theorem
Let $\left({G, \circ}\right)$ be a group.

Let $\phi: G \to G$ be defined such that $\forall g \in G: \phi \left({g}\right) = g \circ g$.

Then $\left({G, \circ}\right)$ is abelian iff $\phi$ is a (group) endomorphism.