I’m trying to access the class name inside my trait of the class that is using the trait. Is there a way to do this?
After much research, I’m not sure this is possible, but figured I’d check here before I tapped out.
I’m trying to access the class name inside my trait of the class that is using the trait. Is there a way to do this?
After much research, I’m not sure this is possible, but figured I’d check here before I tapped out.
It is possible!
I was thinking about the trait and it’s relationship to the class wrong. A trait basically extends the class, so using get_class($this)
inside the trait I get the class of the object using the trait.
Another option is __CLASS__