Skip to content

Commit 6ab0bff

Browse files
committed
Initial import
0 parents  commit 6ab0bff

42 files changed

Lines changed: 1959 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Coding Standards
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
Tests:
9+
name: Coding Standards (PHP ${{ matrix.php }})
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php:
15+
- 8.1
16+
- 8.2
17+
- 8.3
18+
- 8.4
19+
- 8.5
20+
continue-on-error: ${{ matrix.php == '8.5' }}
21+
steps:
22+
- name: Check out Source Code
23+
uses: actions/checkout@v4
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
coverage: xdebug
30+
31+
- name: Install Dependencies with Composer
32+
run: composer install --ignore-platform-req=php+
33+
34+
- name: Verify Coding Standards
35+
run: vendor/bin/phpcs
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
Tests:
9+
name: Static Analysis (PHP ${{ matrix.php }})
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php:
15+
- 8.1
16+
- 8.2
17+
- 8.3
18+
- 8.4
19+
- 8.5
20+
continue-on-error: ${{ matrix.php == '8.5' }}
21+
steps:
22+
- name: Check out Source Code
23+
uses: actions/checkout@v4
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
coverage: xdebug
30+
31+
- name: Install Dependencies with Composer
32+
run: composer install --ignore-platform-req=php+
33+
34+
- name: Static Code Analysis
35+
run: vendor/bin/phpstan

.github/workflows/UnitTests.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
Tests:
9+
name: Unit Tests (PHP ${{ matrix.php }})
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php:
15+
- 8.1
16+
- 8.2
17+
- 8.3
18+
- 8.4
19+
- 8.5
20+
continue-on-error: ${{ matrix.php == '8.5' }}
21+
steps:
22+
- name: Check out Source Code
23+
uses: actions/checkout@v4
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
coverage: xdebug
30+
31+
- name: Install Dependencies with Composer
32+
run: composer install --ignore-platform-req=php+
33+
34+
- name: Unit Tests
35+
run: vendor/bin/phpunit --testdox

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor/
2+
/.idea/
3+
.*.sw[op]
4+
composer.lock
5+
/tests/.phpunit*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2024 Thomas Gelf
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SNMP Engine
2+
===========
3+
4+
This engine is currently suitable for polling purposes only, but could easily
5+
be extended.

phpcs.xml.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHP_CodeSniffer">
3+
<description>PSR12 Coding Standard</description>
4+
5+
<file>src/</file>
6+
<file>tests/</file>
7+
8+
<arg value="wps"/>
9+
<arg name="colors"/>
10+
<arg name="report-width" value="auto"/>
11+
<arg name="report-full"/>
12+
<arg name="report-gitblame"/>
13+
<arg name="report-summary"/>
14+
<arg name="encoding" value="UTF-8"/>
15+
16+
<rule ref="PSR12"/>
17+
</ruleset>

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 9
3+
paths:
4+
- src
5+
- tests

phpunit.xml.dist

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
4+
colors="true"
5+
cacheResult="false"
6+
processIsolation="false"
7+
stopOnFailure="false"
8+
bootstrap="vendor/autoload.php"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false"
12+
>
13+
<testsuites>
14+
<testsuite name="Test Suite">
15+
<directory suffix="Test.php">./tests/</directory>
16+
</testsuite>
17+
</testsuites>
18+
<coverage/>
19+
<source>
20+
<include>
21+
<directory suffix=".php">src</directory>
22+
</include>
23+
</source>
24+
</phpunit>

src/Application/OidHelper.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace IMEdge\SnmpEngine\Application;
4+
5+
use IMEdge\SnmpPacket\Message\VarBind;
6+
use IMEdge\SnmpPacket\Message\VarBindList;
7+
8+
class OidHelper
9+
{
10+
/**
11+
* @param array<string, ?string> $oids
12+
*/
13+
public static function oidsToVarBindList(array $oids): VarBindList
14+
{
15+
return new VarBindList(self::oidsToVarBindsForRequest($oids));
16+
}
17+
18+
/**
19+
* @param array<string, ?string> $oids
20+
* @return VarBind[]
21+
*/
22+
public static function oidsToVarBindsForRequest(array $oids): array
23+
{
24+
$varBinds = [];
25+
$i = 0;
26+
foreach (array_keys($oids) as $oid) {
27+
$i++;
28+
$varBinds[$i] = new VarBind($oid);
29+
}
30+
31+
return $varBinds;
32+
}
33+
}

0 commit comments

Comments
 (0)