Skip to content

Commit

Permalink
Issue #2 Fixed fp close logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehaertl committed Feb 16, 2017
1 parent 19048ed commit ecfeeef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ class Target extends BaseTarget

protected $fp;

protected $openedFp = false;

/**
* @inheritdoc
*/
public function __destruct()
{
if (!empty($this->url)) {
if ($this->openedFp) {
fclose($this->fp);
}
}
Expand Down Expand Up @@ -69,6 +71,7 @@ public function getFp()
if ($this->fp===false) {
throw new InvalidConfigException("Unable to open '{$this->url}' for writing.");
}
$this->openedFp = true;
}
return $this->fp;
}
Expand Down

0 comments on commit ecfeeef

Please sign in to comment.