code: public function setGroups(array $groups)
      {
          $this->groups = [];
  
          foreach ($groups as $item) {
              $this->addGroup($item);
          }
  
          return $this;
      }
docs: Sets the "groups" of the User.
  
  @param Group[] $groups
  
  @return User