src/package/Support/jasonlewis/resource-watcher/src/JasonLewis/ResourceWatcher/Watcher.php
public function watch($resource)
    {
        if (!$this->files->exists($resource)) {
            throw new RuntimeException('Resource must exist before you can watch it.');
        } elseif ($this->files->isDirectory($resource)) {
            $resource = new DirectoryResource(new SplFileInfo($resource), $this->files);

            $resource->setupDirectory();
        } else {
            $resource = new FileResource(new SplFileInfo($resource), $this->files);
        }

        // The listener gives users the ability to bind listeners on the events
        // created when watching a file or directory. We'll give the listener
        // to the tracker so the tracker can fire any bound listeners.
        $listener = new Listener();

        $this->tracker->register($resource, $listener);

        return $listener;
    }
public function watch($resource)
    {
        if (!$this->files->exists($resource)) {
            throw new RuntimeException('Resource must exist before you can watch it.');
        } elseif ($this->files->isDirectory($resource)) {
            $resource = new DirectoryResource(new SplFileInfo($resource), $this->files);

            $resource->setupDirectory();
        } else {
            $resource = new FileResource(new SplFileInfo($resource), $this->files);
        }

        // The listener gives users the ability to bind listeners on the events
        // created when watching a file or directory. We'll give the listener
        // to the tracker so the tracker can fire any bound listeners.
        $listener = new Listener();

        $this->tracker->register($resource, $listener);

        return $listener;
    }
public function watch ( $ resource ) { if ( ! $ this -> files -> exists ( $ resource ) ) { throw new RuntimeException ( 'Resource must exist before you can watch it.' ) ; } elseif ( $ this -> files -> isDirectory ( $ resource ) ) { $ resource = new DirectoryResource ( new SplFileInfo ( $ resource ) , $ this -> files ) ; $ resource -> setupDirectory ( ) ; } else { $ resource = new FileResource ( new SplFileInfo ( $ resource ) , $ this -> files ) ; } // The listener gives users the ability to bind listeners on the events // created when watching a file or directory. We'll give the listener // to the tracker so the tracker can fire any bound listeners. $ listener = new Listener ( ) ; $ this -> tracker -> register ( $ resource , $ listener ) ; return $ listener ; }
Register a resource to be watched.

@param string $resource

@return \JasonLewis\ResourceWatcher\Listener
Register a resource to be watched .