/**
  * Returns TRUE when the given Track's request matches the given request.
  *
  * @param TrackInterface   $track   The track.
  * @param RequestInterface $request The request.
  *
  * @return bool TRUE if the Track's request matches the given request, FALSE if not.
  */
 public function matchByRequest(TrackInterface $track, RequestInterface $request)
 {
     $trackRequestData = $this->converter->requestToArray($track->getRequest());
     $requestData = $this->converter->requestToArray($request);
     // If the diff is empty, this means that all keys from the Track request are available in the array
     // from the other request, so they can be considered equal.
     $diff = $this->array_diff_assoc_recursive($requestData, $trackRequestData);
     $isEqual = empty($diff);
     return $isEqual;
 }
Ejemplo n.º 2
0
 public function writeTrack(TrackInterface $track)
 {
     $newTracks = [];
     foreach ($this->tracks as $key => $existing) {
         if (!$this->trackMatcher->matchByRequest($existing, $track->getRequest())) {
             $newTracks[] = $existing;
         }
     }
     $newTracks[] = $track;
     $this->tracks = $newTracks;
 }