<?php

interface Device {

    public function __construct (DevicesGroup $group);

    public function setUid (string $uid): void;

    public function save (): void;
}


class Computer implements Device {

    private $uid;
    private $group;

    public function __construct (DevicesGroup $group) {
        $this->group = $group;
    }

    public function setUid (string $uid): void {
        $this->uid = $uid;
    }

    public function save (): void {
        echo "Saving device with UID {$this->uid} to group {$this->group->getName()}" . PHP_EOL;
    }
}


class DevicesGroup {

    public $name;
    public $location;

    public function __construct (string $name, string $location) {
        $this->name = $name;
        $this->location = $location;
    }

    public function getName (): string {
        return $this->name;
    }

    public function getLocation (): string {
        $this->location;
    }
}


// USAGE
$greenGroup = new DevicesGroup("Green", "Warsaw");
$computer = new Computer($greenGroup);

$uids = [
    "aaa",
    "bbb",
    "ccc",
    "ddd",
    "eee",
    "fff",
    "ggg"
];

foreach ($uids as $uid) {
    $device = clone $computer;
    $device->setUid($uid);
    $device->save();
}