Source of file Arrayable.php

Size: 0,726 Bytes - Last Modified: 2018-11-03T09:50:48-04:00

G:/AdobeConnectClient/src/Traits/Arrayable.php

12345678910111213141516171819202122232425262728293031323334
<?php

namespace AdobeConnectClient\Traits;

use AdobeConnectClient\Helpers\StringCaseTransform as SCT;
use AdobeConnectClient\Helpers\ValueTransform as VT;

/**
 * Override the methods to turn into a valid ArrayableInterface
 */
trait Arrayable
{
    /**
     * Retrieves all not null attributes in an associative array
     *
     * The keys in hash style: Ex: is-member
     * The values as string
     *
     * @return string[]
     */
    public function toArray()
    {
        $values = [];

        foreach ($this as $prop => $value) {
            if (!isset($value)) {
                continue;
            }
            $values[SCT::toHyphen($prop)] = VT::toString($value);
        }
        return $values;
    }
}