<?php

namespace Howtomakeaturn\Db2d;

use Ifsnop\Mysqldump\Mysqldump;
use Kunnu\Dropbox\DropboxApp;
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxFile;

class Db2d
{
    private $dumper;

    private $uploader;

    public function configureDatabase($db, $username, $password)
    {
        $this->dumper = new Mysqldump("mysql:host=localhost;dbname=$db", $username, $password);
        
        return $this;
    }

    public function configureDropbox($key, $secret, $token)
    {
        $app = new DropboxApp($key, $secret, $token);

        $this->uploader = new Dropbox($app);
        
        return $this;
    }

    public function backup()
    {
        $name = 'backup-' . date('Ymd-H-i-s') . '.sql';

        $this->dumper->start($name);

        $dropboxFile = new DropboxFile($name);

        $file = $this->uploader->upload($dropboxFile, "/$name", ['autorename' => true]);

        unlink($name);
    }
}

<?php

namespace Howtomakeaturn\Db2d;

use Ifsnop\Mysqldump\Mysqldump;
use Kunnu\Dropbox\DropboxApp;
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxFile;

class Db2d
{
    private $dumper;

    private $uploader;

    public function configureDatabase($db, $username, $password)
    {
        $this->dumper = new Mysqldump("mysql:host=localhost;dbname=$db", $username, $password);
    }

    public function configureDropbox($key, $secret, $token)
    {
        $app = new DropboxApp($key, $secret, $token);

        $this->uploader = new Dropbox($app);
    }

    public function backup()
    {
        $name = 'backup-' . date('Ymd-H-i-s') . '.sql';

        $this->dumper->start($name);

        $dropboxFile = new DropboxFile($name);

        $file = $this->uploader->upload($dropboxFile, "/$name", ['autorename' => true]);

        unlink($name);
    }
}

--- 
+++ 
@@ -16,6 +16,8 @@
     public function configureDatabase($db, $username, $password)
     {
         $this->dumper = new Mysqldump("mysql:host=localhost;dbname=$db", $username, $password);
+        
+        return $this;
     }
 
     public function configureDropbox($key, $secret, $token)
@@ -23,6 +25,8 @@
         $app = new DropboxApp($key, $secret, $token);
 
         $this->uploader = new Dropbox($app);
+        
+        return $this;
     }
 
     public function backup()
Allow configuration methods to be chained.