checks if given used space exceeda quota limit


@param     int   $usedSpace
@return    int
16756
public function spaceLeft(int $usedSpace): int
    {
        if (self::UNLIMITED === $this->amount) {
            return $usedSpace;
        }

        if ($usedSpace >= $this->amount) {
            return 0;
        }

        $spaceLeft = $this->amount - $usedSpace;
        if (0 >= $spaceLeft) {
            return 0;
        }

        return $spaceLeft;
    }
709848
public function getMostUsedVatPercent()
    {
        $aPrices = $this->getPriceInfo();
        if (count($aPrices) == 0) {
            return;
        }

        return max(array_keys($aPrices, max($aPrices)));
    }
1217993
private function checkLivePermissionForAllWebspaces()
    {
        foreach ($this->get('sulu_core.webspace.webspace_manager')->getWebspaceCollection() as $webspace) {
            $context = PageAdmin::SECURITY_CONTEXT_PREFIX . $webspace->getKey();
            if (!$this->get('sulu_security.security_checker')->hasPermission($context, PermissionTypes::LIVE)) {
                return false;
            }
        }

        return true;
    }
129508
private function evaluateMatchingAnyLimitation(
        array $languageCodesList,
        array $limitationValues
    ): bool {
        return empty(array_intersect($languageCodesList, $limitationValues))
            ? self::ACCESS_DENIED
            : self::ACCESS_GRANTED;
    }
998768
private function checkCount(){
        $cnt = (int) $this->getMaxEntries();
        if ($cnt !== NULL && count($this->values) !== $cnt){
            trigger_error("Wrong count of Elements. Expected are $cnt. But right now there are ". count($this->values));
        }

    }
309644
protected function getLimit($limit = null)
    {
        if (null === $limit) {
            $limit = $this->getDefaultLimit();
        }

        return $this->validateLimit($limit);
    }
604923
protected function _getLimit($iStart)
    {
        $iLimit = (int) \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("results");
        $iLimit = $iLimit ? $iLimit : $this->_iSqlLimit;

        return " limit $iStart, $iLimit ";
    }
418340
public function limitExceeded()
    {
        $limit = $this->_agent->getLimit();
        return $limit != CollectionAgentAbstract::NO_LIMIT && $this->_count > $this->_agent->getLimit();
    }
356449
def verify_space_available(self, search_pattern=r"(\d+) \w+ free"):
        """"""
        if self.direction == "put":
            space_avail = self.remote_space_available(search_pattern=search_pattern)
        elif self.direction == "get":
            space_avail = self.local_space_available()
        if space_avail > self.file_size:
            return True
        return False
483938
function limitationList( $useCache = true, $ignoreLimitIdentifier = false )
    {
        if ( !isset( $this->Limitations ) || !$useCache )
        {

            $limitations = eZPersistentObject::fetchObjectList( eZPolicyLimitation::definition(),
                                                                 null, array( 'policy_id' => $this->attribute( 'id') ), null, null,
                                                                 true );

            eZDebugSetting::writeDebug( 'kernel-policy-limitation', $limitations, "before policy limitations " . $this->ID );
            eZDebugSetting::writeDebug( 'kernel-policy-limitation', $this, "policy itself before before limitations check"  );

            if ( $ignoreLimitIdentifier === false  && isset( $this->LimitIdentifier ) && $this->LimitIdentifier )
            {
                $limitIdentifier =  $this->attribute( 'limit_identifier' );
                $limitValue = $this->attribute( 'limit_value' );
                $limitationTouched = false;
                $checkEmptyLimitation = true;
                foreach ( $limitations as $limitation )
                {
                    if ( $limitation->attribute( 'identifier' ) == $limitIdentifier )
                    {
                        if ( $limitIdentifier == 'Subtree' )
                        {
                            $limitationTouched = true;

                            $values = $limitation->attribute( 'values' );

                            foreach ( $values as $limitationValue )
                            {
                                $value = $limitationValue->attribute( 'value' );
                                if ( strpos( $value, $limitValue ) === 0 )
                                {
                                    $checkEmptyLimitation = false;
                                    eZDebugSetting::writeDebug( 'kernel-policy-limitation', $value,
                                                                "Limitationvalue has been left in the limitation [limitValue=$limitValue]" );
                                }
                                else if ( strpos( $limitValue, $value ) === 0 )
                                {
                                    $checkEmptyLimitation = false;
                                    $limitationValue->setAttribute( 'value', $limitValue );
                                    eZDebugSetting::writeDebug(  'kernel-policy-limitation',
                                                                 $value,
                                                                 "Limitationvalue has been exchanged to the value from cond assignment [limitValue=$limitValue]" );
                                }
                                else
                                {
                                    eZDebugSetting::writeDebug(  'kernel-policy-limitation',  $value,
                                                                 "Limitationvalue has been removed from limitation [limitValue=$limitValue]" );
                                    //exlude limitation value from limitation..
                                    unset( $limitationValue );
                                }
                            }
                            if ( $checkEmptyLimitation )
                            {
                                eZDebugSetting::writeDebug( 'kernel-policy-limitation', $this, 'The policy has been disabled' );
                                $this->Disabled = true;
                                $this->Limitations = array();
                                return $this->Limitations;
                            }
                        }
                    }
                }

                if ( !$limitationTouched )
                {
                    $policyLimitation = new eZPolicyLimitation( array ( 'id' => -1,
                                                                        'policy_id' => $this->attribute( 'id' ),
                                                                        'identifier' => $this->attribute( 'limit_identifier' ) ) );
                    $policyLimitation->setAttribute( 'limit_value', $this->attribute( 'limit_value' ) );

                    $limitations[] = $policyLimitation;
                }
            }
            eZDebugSetting::writeDebug( 'kernel-policy-limitation', $limitations, "policy limitations " . $this->ID );

            $this->Limitations = $limitations;
        }
        return $this->Limitations;
    }
565186
public function findLimited($from, $to, $arg = null, $operator = '=', $fields = array('*'))
    {
        return $this->find($arg, $operator, $fields)->limit($from, $to);
    }
727887
public function get_quota($folder = null)
    {
        if ($this->get_capability('QUOTA') && $this->check_connection()) {
            return $this->conn->getQuota($folder);
        }

        return false;
    }
805838
function limitList( $useGroupsCache = true )
    {
        if ( $useGroupsCache )
            $groups = $this->groups();
        else
            $groups = $this->generateGroupIdList();
        $groups[] = $this->attribute( 'contentobject_id' );
        $groups = implode( ', ', $groups );

        $db = eZDB::instance();

        $limitationsArray = $db->arrayQuery( "SELECT DISTINCT limit_identifier, limit_value
                                              FROM ezuser_role
                                              WHERE contentobject_id IN ( $groups )" );

        return $limitationsArray;
    }
1201180
def enter_into_queue? # Check if enough space in queue
      current_limit = queue_constraints[:capacity].to_i
      current_usage = queue_constraints[:taken].to_i + UserQ::UserQueue.count_unexpired(queue_constraints[:context])

      # Assess whether enough space left into queue
      current_usage < current_limit
    end
519118
public function isValidExtension()
    {
        return !count($this->allowedExtensions)
            || in_array($this->getFileExtension(), $this->allowedExtensions, true);
    }
585801
private function compareUseStatementsByContent(UseStatement $prevStatement, UseStatement $nextStatement): ?int
    {
        $compareByContent = null;

        $prevParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName());
        $nextParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName());

        $minPartsCount = min(count($prevParts), count($nextParts));

        for ($i = 0; $i < $minPartsCount; ++$i) {
            $comparison = strcasecmp($prevParts[$i], $nextParts[$i]);

            if ($comparison) {
                $compareByContent = $comparison;
                break;
            }
        }

        return $compareByContent;
    }
987405
def _check_available_disk_space(self, project):
        

        try:
            used_disk_space = psutil.disk_usage(project.path).percent
        except FileNotFoundError:
            log.warning('Could not find "{}" when checking for used disk space'.format(project.path))
            return
        # send a warning if used disk space is >= 90%
        if used_disk_space >= 90:
            message = 'Only {}% or less of disk space detected in "{}" on "{}"'.format(used_disk_space,
                                                                                       project.path,
                                                                                       platform.node())
            log.warning(message)
            project.emit("log.warning", {"message": message})