<?php declare(strict_types=1);

/* (c) Anton Medvedev <anton@medv.io>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Deployer\Support;

class ObjectProxy
{
    /**
     * @var array
     */
    private $objects;

    public function __construct(array $objects)
    {
        $this->objects = $objects;
    }

    public function __call(string $name, array $arguments): self
    {
        foreach ($this->objects as $object) {
            $object->$name(...$arguments);
        }
        return $this;
    }
}
