original_string: public function saveBrick($slug, $postValues)
      {
          $brickObject = BrickFactory::createBrickFromPostValues($postValues);
  
          $bricks = $this->repository->bricks;
          foreach ($bricks as $key => $brick) {
              if ($brick->slug == $slug) {
                  $bricks[$key] = $brickObject;
              }
          }
          $this->repository->bricks = $bricks;
          $this->save();
      }
code: public function saveBrick($slug, $postValues)
      {
          $brickObject = BrickFactory::createBrickFromPostValues($postValues);
  
          $bricks = $this->repository->bricks;
          foreach ($bricks as $key => $brick) {
              if ($brick->slug == $slug) {
                  $bricks[$key] = $brickObject;
              }
          }
          $this->repository->bricks = $bricks;
          $this->save();
      }
code_tokens: public function saveBrick ( $ slug , $ postValues ) { $ brickObject = BrickFactory :: createBrickFromPostValues ( $ postValues ) ; $ bricks = $ this -> repository -> bricks ; foreach ( $ bricks as $ key => $ brick ) { if ( $ brick -> slug == $ slug ) { $ bricks [ $ key ] = $ brickObject ; } } $ this -> repository -> bricks = $ bricks ; $ this -> save ( ) ; }
docstring: Save changes to a brick
  
  @param $slug
  @param $postValues
  
  @throws \Exception
docstring_tokens: Save changes to a brick