Solidity contract compiler

Could this logic be encapsulated into a static class method?