Add a device to this collection.

@param DeviceInterface $device The device to add

@return $this
549797
public function addDevice(DeviceInterface $device): CollectionInterface
    {
        # Replace any existing device with the same IP address
        foreach ($this->devices as &$val) {
            if ($val->getIp() === $device->getIp()) {
                $val = $device;
                return $this;
            }
        }

        $this->devices[] = $device;

        return $this;
    }
1107702
public function add(CriterionInterface $criterion): self
    {
        if (! $criterion->isAttached()) {
            $criterion->attach($this);
        }

        $this->criteria[] = $criterion;

        return $this;
    }
1011669
public function addGroup(GroupInterface $group)
    {
        if (!$this->hasGroup($group)) {
            $this->groups->set($group->getName(), $group);
            $group->addUser($this);
        }

        return $this;
    }
216788
public function push(PushInterface $push)
    {
        $client        = $this->getOpenedClient();
        $pushedDevices = new DeviceCollection();
        $tokens        = array_chunk($push->getDevices()->getTokens(), 100);

        foreach ($tokens as $tokensRange) {
            $message = $this->getServiceMessageFromOrigin($tokensRange, $push->getMessage());

            try {

                /** @var \ZendService\Google\Gcm\Response $response */
                $response        = $client->send($message);
                $responseResults = $response->getResults();

                foreach ($tokensRange as $token) {
                    /** @var DeviceInterface $device */
                    $device = $push->getDevices()->get($token);

                    // map the overall response object
                    // into a per device response
                    $tokenResponse = [];
                    if (isset($responseResults[$token]) && is_array($responseResults[$token])) {
                        $tokenResponse = $responseResults[$token];
                    }

                    $responseData = $response->getResponse();
                    if ($responseData && is_array($responseData)) {
                        $tokenResponse = array_merge(
                            $tokenResponse,
                            array_diff_key($responseData, ['results' => true])
                        );
                    }

                    $push->addResponse($device, $tokenResponse);

                    $pushedDevices->add($device);

                    $this->response->addOriginalResponse($device, $response);
                    $this->response->addParsedResponse($device, $tokenResponse);
                }
            } catch (ServiceRuntimeException $e) {
                throw new PushException($e->getMessage());
            }
        }

        return $pushedDevices;
    }
449736
public function setDevices(array $devices)
    {
        $this->devices = $devices;

        $this->hostConfig = array_merge($this->hostConfig, ['Devices' => $devices]);

        return $this;
    }
15728
public function patch(ModelDeviceInterface $device, ModelDeviceInterface $patchingDevice)
    {
        if (!$this->haveSameId($device, $patchingDevice)) {
            return $patchingDevice;
        }

        $groupIdCapabilitiesMap = Utils::arrayMergeRecursiveUnique(
            $device->getGroupIdCapabilitiesMap(),
            $patchingDevice->getGroupIdCapabilitiesMap()
        );

        return new ModelDevice($device->id, $device->userAgent, $device->fallBack, $device->actualDeviceRoot, $device->specific, $groupIdCapabilitiesMap);
    }
356274
public function add(ElementInterface $element)
    {
        if (null === $element->getName()) {
            $this->data[] = $element;
            return $this;
        }
        $this->data[$element->getName()] = $element;
        return $this;
    }
460531
public function add(HeaderInterface $header)
    {
        $this->headers[strtolower($header->getName())] = $header;

        return $this;
    }
1183231
public function add($item)
    {
        foreach ($this->_requiredInterfaces as $interface) {
            if (!$item instanceof $interface) {
                throw new RuntimeException(
                    sprintf('Item "%s" should implement "%s" interface', get_class($item), $interface)
                );
            }
        }
        
        $this->_items[spl_object_hash($item)] = $item;
        return $this;
    }
887970
public function add(iterable $elements): CollectionInterface
    {
        foreach ($elements as $key => $element) {
            $this->set($key, $element);
        }

        return $this;
    }
941272
public function addDriver(DriverInterface $driver)
    {
        $driver->setConnector($this);
        $this->driverList[$driver->getDriverId()] = $driver;

        return $this;
    }
503931
public function addAll($elements)
    {
        if ($elements instanceof CollectionInterface) {
            $elements = $elements->toArray();
        } else {
            $elements = array_values($elements);
        }
        $this->elements = array_merge($this->elements, $elements);
        return $this;
    }
1203840
public function addItem(ItemInterface $item)
    {
        $this->itemsChanged = true;
        $this->entity->addItem($item);

        return $this;
    }
825920
protected synchronized void addDeviceToStore(AndroidDevice device) throws AndroidDeviceException {
    if (androidDevices.containsKey(device.getTargetPlatform())) {
      List<AndroidDevice> platformDevices = androidDevices.get(device.getTargetPlatform());
      if (!platformDevices.contains(device)) {
        platformDevices.add(device);
      }
    } else {
      androidDevices.put(device.getTargetPlatform(), Lists.newArrayList(device));
    }
  }
825373
public function addItem(ItemInterface $item)
    {
        if ($this->hasItem($item->getId()) === true) {
            throw new \RuntimeException(sprintf('A previous item exists with the same id: "%s".', $item->getId()));
        }

        $this->items[$item->getId()] = $item;
    }
947761
public function setDeviceDetail(\BlackForest\PiwikBundle\Entity\PiwikDevice $deviceDetail = null)
    {
        $this->deviceDetail = $deviceDetail;

        return $this;
    }
498490
public static function device(
        Authorization $authorization,
        ClientInterface $client = null,
        SerializerInterface $serializer = null
    ) {
        AnnotationRegistry::registerLoader('class_exists');

        $afterpayClient = $client ?: new Client([ 'base_uri' => $authorization->getEndpoint() ]);
        $afterpaySerializer = $serializer ?: SerializerFactory::getSerializer();

        return new Service\InStore\Device($authorization, $afterpayClient, $afterpaySerializer);
    }