The very basic example and possibly the most used in real-life app is a protected/private property with a setter method. And the benefit is obvious - you can protect that property from the setter, thus making sure it will always contain the type of variable you expect it to have. Example:
class Subscribe {
/** App\User **/
protected $user;
public function setUser(\App\User $user) : self
{
$this->user = $user;
return $this;
}
// in projects using php5 you may see things like this
// same idea but we add additional if because we can't type-hint a string
protected $name;
public function setName($name)
{
if (!is_string($name)) {
throw new Exception('Name must be string');
}
$this->name = $name;
}
}
A real-life example for methods is from Controller:
public function show()
{
// this is public, so we expect it to be associated with some route
}
private function upload()
{
// this is private, so we know we only use it from the current controller (by the time we see "private" or "protected" we are already know that this is not associated with any route but is a helper method)
}
Most of the time you will use public tho, but don't make public things that you know you would never use outside of the class.
Hopefully that helped you a little bit as I can't really explain where and how to encapsulate your data. Most probably some people will advise you to read more about OOP and encapsulation but I think most people are getting better at this just by reading and writing more code.