PHP code example of mover-io / belt

1. Go to this page and download the library: Download mover-io/belt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mover-io / belt example snippets


Belt\Trace::debug($your_result);
// with Stack Trace
Belt\Trace::traceDepth(7)->debug($your_result);

$route = Belt\Text::ensureNoPrefix($route, "/v2/");
$route = Belt\Text::ensureNoSuffix($route, "/");

// Safe getter that returns null if no value for key
$value = Belt\Array::get($array, 'key', null)

 namespace Mover\Connectors\Sharing;

use Belt\SchemaObject;
use Belt\Arrays;

class UserInfo extends SchemaObject
{
    protected static $attribute_spec = array(
        'first_name'  => array('type' => 'string'),
        'last_name'   => array('type' => 'string'),
        'email'       => array('type' => 'string'),
        // E.g. this could be an id from the migration source system.
        'external_id' => array('type' => 'string'),
        // The users id' in the active connector.
        'id'          => array('type' => 'string'),
        // The raw data from the third party if available. This is optional.
        // Code should never rely on a raw field. We may use it for debugging
        // and introspection.
        'raw'         => array('type' => 'array')
    );

    public function fullname()
    {
        return implode(
            ' ',
            array_filter(
                array($this->first_name, $this->last_name)
            )
        );
    }

    /**
     * Splits a full name (first + last name) into an array of two parts, the
     * first and last name. Note that this assumes only a single space separates
     * the first and last name.
     */
    public static function splitName($fullname)
    {
          $name_parts = explode(" ", $fullname, 2);
          $first_name = Arrays::get($name_parts, 0, "");
          $last_name  = Arrays::get($name_parts, 1, "");
          return array($first_name, $last_name);
    }
}