original_string: public function setData($collection, $resource_name = '')
      {
          $this->collection = collect();
  
          if (!$this->resource_name) {
              $this->resource_name = empty($resource_name) ? 'undefined' : $resource_name;
          }
  
          $this->data = [];
          
          foreach ($collection as $item) {
              $this->collection->push(clone $item);
              $i = new Item($item, $this->resource_name);
              array_push($this->data, $i->getData());
          }
          $this->response['data'] = $this->data;
      }
code: public function setData($collection, $resource_name = '')
      {
          $this->collection = collect();
  
          if (!$this->resource_name) {
              $this->resource_name = empty($resource_name) ? 'undefined' : $resource_name;
          }
  
          $this->data = [];
          
          foreach ($collection as $item) {
              $this->collection->push(clone $item);
              $i = new Item($item, $this->resource_name);
              array_push($this->data, $i->getData());
          }
          $this->response['data'] = $this->data;
      }
code_tokens: public function setData ( $ collection , $ resource_name = '' ) { $ this -> collection = collect ( ) ; if ( ! $ this -> resource_name ) { $ this -> resource_name = empty ( $ resource_name ) ? 'undefined' : $ resource_name ; } $ this -> data = [ ] ; foreach ( $ collection as $ item ) { $ this -> collection -> push ( clone $ item ) ; $ i = new Item ( $ item , $ this -> resource_name ) ; array_push ( $ this -> data , $ i -> getData ( ) ) ; } $ this -> response [ 'data' ] = $ this -> data ; }
docstring: Set collection data
  
  @param type $collection
  @param string $resource_name
docstring_tokens: Set collection data