public function setStockLevel(Unit $unit, array $row, $location = 'web')
 {
     $stockKey = $this->_headingKeys->getKey('stock');
     if (!is_string($location) && !$location instanceof Location\Location) {
         throw new \InvalidArgumentException('Location must be either a string or an instance of Location');
     } elseif (!array_key_exists($stockKey, $row)) {
         throw new \LogicException('No stock column in row!');
     }
     $stockLevel = (int) $row[$stockKey];
     if ($stockLevel > 0) {
         $location = $location instanceof Location\Location ? $location : $this->_locations->get($location);
         $this->_stockManager->setReason($this->_reason);
         $this->_stockManager->set($unit, $location, $stockLevel);
     }
 }
 protected function _saveStockForBarcode($barcode, $stockLevel)
 {
     $this->writeln('Setting stock level of `' . $barcode . '` in `' . $this->_location->name . '` to ' . $stockLevel);
     $unit = $this->_unitLoader->getByBarcode($barcode);
     if (!$unit) {
         $this->writeln('<error>Unit with a barcode of `' . $barcode . '` could not be found, so it will be skipped</error>');
     } else {
         $this->_stockManager->set($unit, $this->_location, $stockLevel);
     }
 }